pyradius / pyrad

Python RADIUS Implementation
BSD 3-Clause "New" or "Revised" License
295 stars 186 forks source link

server Unreachable #123

Open FahadNaim opened 4 years ago

FahadNaim commented 4 years ago

Hi dears, I am doing my project for authentications. I do implement two python scripts for pyrad RADIUS Server and Clints. Both are run, the message sent from the client, however it's do not reach the server, where i run the wireshark which show me the ICMP (port unreachable, UDP RADIUS 1812). Can any one help me please. Thanks in advance.

GIC-de commented 4 years ago

Maybe you bound the server to wrong address?

FahadNaim commented 4 years ago

Thank You Mr. GIC-de Note: I do run the code in Ubuntu installed at VirtualBox. I have used several available blogs on the internet, one of them was this: Example

Here is an example of doing an authentication request:

import pyrad.packet from pyrad.client import Client from pyrad.dictionary import Dictionary

srv=Client(server="radius.my.domain", secret="s3cr3t", dict=Dictionary("dicts/dictionary", "dictionary.acc"))

req=srv.CreateAuthPacket(code=pyrad.packet.AccessRequest, User_Name="wichert", NAS_Identifier="localhost") req["User-Password"]=req.PwCrypt("password")

reply=srv.SendPacket(req) if reply.code==pyrad.packet.AccessAccept: print "access accepted" else: print "access denied"

print "Attributes returned by server:" for i in reply.keys(): print "%s: %s" % (i, reply[i])

And an example for a trivial RADIUS server:

from pyrad import dictionary, packet, server

class FakeServer(server.Server): def _HandleAuthPacket(self, fd, pkt): server.Server._HandleAuthPacket(self, fd, pkt)

      reply=self.CreateReplyPacket(pkt)
      reply.code=packet.AccessAccept
      self.SendReplyPacket(fd, reply)

srv=FakeServer(dict=dictionary.Dictionary("dictionary")) srv.hosts["127.0.0.1"]=server.RemoteHost("127.0.0.1", "s3cr3t", "localhost") srv.BindToAddress("") srv.Run()

from: https://mail.python.org/pipermail/python-announce-list/2004-August/003328.html however, all are the same problem.

mbish commented 4 years ago

I have also encountered this. Unless I'm missing something, leaving an empty string to indicate listening on all interfaces is currently broken. Specify an interface in your call to BindToAddress for now.