TechnitiumSoftware / DnsServer

Technitium DNS Server
https://technitium.com/dns/
GNU General Public License v3.0
4.47k stars 431 forks source link

DHCP is leasing wrong IP #870

Closed FabioEight closed 8 months ago

FabioEight commented 8 months ago

Hello, I'm running Technitium in a VyOS container with host network capabilities, but I faced this issue also on a dedicated LXC with only Technitium. It seems that after some time, if a device request a new IP address or if I manually trigger a DHCP request, Technitium provides a different IP and not the previous/statically reserved IP. This happens with multiple devices so it's not OS related.

IP reservation set on Technitium: image

15:39:05.357281 8e:bc:b2:YY:YY:YY > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 342: (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328)
    0.0.0.0.68 > 255.255.255.255.67: [udp sum ok] BOOTP/DHCP, Request from 8e:bc:b2:YY:YY:YY, length 300, xid 0x16a80d7e, Flags [none] (0x0000)
          Client-Ethernet-Address 8e:bc:b2:YY:YY:YY
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message (53), length 1: Discover
            Requested-IP (50), length 4: 192.168.1.25
            Hostname (12), length 4: "8e:bc:b2:XX:XX:XX"
            Parameter-Request (55), length 13: 
              Subnet-Mask (1), BR (28), Time-Zone (2), Default-Gateway (3)
              Domain-Name (15), Domain-Name-Server (6), Unknown (119), Hostname (12)
              Netbios-Name-Server (44), Netbios-Scope (47), MTU (26), Classless-Static-Route (121)
              NTP (42)
15:39:05.359393 bc:24:11:7a:fb:2a > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 364: (tos 0x0, ttl 64, id 35730, offset 0, flags [DF], proto UDP (17), length 350)
    192.168.1.254.67 > 255.255.255.255.68: [bad udp cksum 0xc401 -> 0xd263!] BOOTP/DHCP, Reply, length 322, xid 0x16a80d7e, Flags [none] (0x0000)
          Your-IP 192.168.1.101
          Server-IP 192.168.1.254
          Client-Ethernet-Address 8e:bc:b2:YY:YY:YY
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message (53), length 1: Offer
            Server-ID (54), length 4: 192.168.1.254
            Lease-Time (51), length 4: 86400
            RN (58), length 4: 43200
            RB (59), length 4: 75600
            Subnet-Mask (1), length 4: 255.255.255.0
            BR (28), length 4: 192.168.1.255
            Default-Gateway (3), length 4: 192.168.1.1
            Domain-Name (15), length 12: "custom-local-domain.com"
            Domain-Name-Server (6), length 4: 192.168.1.1
            Unknown (119), length 14: 2403,24941,26990,28532,29807,617,29696
15:39:05.359939 8e:bc:b2:YY:YY:YY > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 342: (tos 0x10, ttl 128, id 0, offset 0, flags [none], proto UDP (17), length 328)
    0.0.0.0.68 > 255.255.255.255.67: [udp sum ok] BOOTP/DHCP, Request from 8e:bc:b2:YY:YY:YY, length 300, xid 0x16a80d7e, Flags [none] (0x0000)
          Client-Ethernet-Address 8e:bc:b2:YY:YY:YY
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message (53), length 1: Request
            Server-ID (54), length 4: 192.168.1.254
            Requested-IP (50), length 4: 192.168.1.101
            Hostname (12), length 4: "8e:bc:b2:XX:XX:XX"
            Parameter-Request (55), length 13: 
              Subnet-Mask (1), BR (28), Time-Zone (2), Default-Gateway (3)
              Domain-Name (15), Domain-Name-Server (6), Unknown (119), Hostname (12)
              Netbios-Name-Server (44), Netbios-Scope (47), MTU (26), Classless-Static-Route (121)
              NTP (42)
15:39:05.360356 bc:24:11:7a:fb:2a > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 364: (tos 0x0, ttl 64, id 35731, offset 0, flags [DF], proto UDP (17), length 350)
    192.168.1.254.67 > 255.255.255.255.68: [bad udp cksum 0xc401 -> 0xcf63!] BOOTP/DHCP, Reply, length 322, xid 0x16a80d7e, Flags [none] (0x0000)
          Your-IP 192.168.1.101
          Server-IP 192.168.1.254
          Client-Ethernet-Address 8e:bc:b2:YY:YY:YY
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message (53), length 1: ACK
            Server-ID (54), length 4: 192.168.1.254
            Lease-Time (51), length 4: 86400
            RN (58), length 4: 43200
            RB (59), length 4: 75600
            Subnet-Mask (1), length 4: 255.255.255.0
            BR (28), length 4: 192.168.1.255
            Default-Gateway (3), length 4: 192.168.1.1
            Domain-Name (15), length 12: "custom-local-domain.com"
            Domain-Name-Server (6), length 4: 192.168.1.1
            Unknown (119), length 14: 2403,24941,26990,28532,29807,617,29696

You can see that the new/wrong lease is present on the DHCP client list: image

For the time being, I had this issue only with LXC or VM configured in Proxmox, using standard configurations (virtio, different MAC addresses) as always did flawlessly. I had no similar issues with other DHCP servers so far.

ShreyasZare commented 8 months ago

Thanks for the post. This issue is related to #850.

The root problem in your scenario is that the reserved lease was allocated to the client based on the Client Identifier (option 61) in the original request. So the lease is owned by the device which used the Client Identifier in the request.

Now, the same client requests lease without the same Client Identifier option in the request (probably due to a manual lease renewal command). The DHCP server sees that the reserved leased is already assigned to a specific Client Identifier and thus allocates a dynamic lease instead.

The fix for this is to configure the dhcp client to use hardware or mac as the client identifier as answered here.

The next update for Technitium DNS server will have an "Ignore Client Identifier" option in DHCP scope which will fix this issue when enabled.

ShreyasZare commented 8 months ago

Technitium DNS Server v12.1 is now available which adds Ignore Client Identifier Option in DHCP scopes that fixes this issue. Do update and let me know your feedback.