lvfrazao / dhcppython

Pure Python library for parsing and manipulating DHCP packets
Apache License 2.0
19 stars 14 forks source link

Option 50 (Address Request) in DHCP Request #15

Open osresearch opened 1 year ago

osresearch commented 1 year ago

It seems that dnsmasq will not reply correctly to a DCHP Request packet that does not have option 50 (Address Request) included. According to (this DHCP overview)[https://learn.microsoft.com/en-us/windows-server/troubleshoot/dynamic-host-configuration-protocol-basics], filling in only the Client IP Address is RFC compliant, although on my network dnsmasq doesn't seem to process the DHCPREQUEST packets that arrive if the source IP is 0.0.0.0 and only the ciaddr field is filled in.

Changing the request packet in get_lease() allows my devices to get IP addresses:

        # R
        # dnsmasq wants option field DHCP Requested Address filled in
        option_list = option_list if option_list else options.OptionList()
        option_list.insert(0, options.options.short_value_to_object(50, offer.yiaddr.packed))
        request = packet.DHCPPacket.Request(
            mac_addr,
            int(default_timer() - start),
            tx_id,
            use_broadcast=broadcast,
            option_list=option_list,
            #client_ip=offer.yiaddr,
            relay=relay,
        )