flan / staticdhcpd

A fast, light, extremely customisable DHCP server written in Python
GNU General Public License v3.0
123 stars 42 forks source link

Support for relay agents requiring Option 82 #69

Closed martink2 closed 7 years ago

martink2 commented 7 years ago

We are currently facing problems with newly deployed relay agents against our staticdhcpd server. The agents rely on Circuit ID information to forward the reply to the correct switchport.

Unfortunately we found out that the Option 82 value from the client is not included in the reply packet.

We tried to add the option by putting the following into our loadDHCPPacket function:

relay_agent = source_packet.getOption('relay_agent')
if relay_agent:
    packet.setOption(82, relay_agent, force_selection=True)

Unfortunately to my understanding the loadDHCPPacket function is not called on all requests, we can see that for the following packet, that the function was not called:


REQUEST:INIT-REBOOT from 00:50:56:98:0c:ab for 10.44.105.246 via 10.45.29.3:67

Is there an option available to reflect Option 82 values Back to the client on all requests.

Any help on this issue is greatly appreciated.

Martin

flan commented 7 years ago

It looks like, as long as INIT-REBOOT isn't getting NAKed, it should be going through that process: https://github.com/flan/staticdhcpd/blob/2.0.x/staticDHCPd/staticdhcpdlib/dhcp.py#L594

Would it be possible to get the relevant portion of the logfile with debug verbosity set? That should be enough to trace the logic flow and find out why the function doesn't seem to be getting called.

A copy of the input packet from a PCAP file may also help, but that might be harder to scrub if there's any sensitive information you'd need to remove. It's also likely less immediately helpful than the logging output.

martink2 commented 7 years ago

Thank you for your quick reply, i rechecked and unfortunately found a

if method in ['DISCOVER', 'INFORM', 'REQUEST:RENEW', 'REQUEST:SELECTING']:

Further up in the method which was ignoring the INIT-REBOOT requests. I am very sorry for the inconvenience.