Support for Backup/ Fallback Radius Server or multiple radius server configuration
lalitmsihra87 opened this issue · 1 comments
lalitmsihra87 commented
Seems, multiple radius server configuration is not supported. Multiple radius server to fallback on other server in case of other radius are down..
Please suggest.
steinsag commented
I implemented it myself by iterating over list of servers as long as I don't receive a reply. Example:
import socket
import pyrad.packet
from pyrad.client import Client
from pyrad.dictionary import Dictionary
username = 'exampleUser'
password = 'TOP-PASSWORD'
secret = 'RADIUS-SECRET'
servers = ['server1', 'server2']
reply = None
response = []
for server in servers:
srv = Client(server=server, secret=str.encode(secret), dict=Dictionary("dictionary.txt"))
srv.timeout = 1
srv.retries = 1
# create request
req = srv.CreateAuthPacket(code=pyrad.packet.AccessRequest,
User_Name=username)
req["Password"] = req.PwCrypt(password)
# send request
try:
reply = srv.SendPacket(req)
break
except pyrad.client.Timeout:
response.append("Timeout exception for server {}".format(server))
continue
except socket.error:
response.append("socket.error exception for server {}".format(server))
continue
I hope, this helps.