openwrt / odhcpd

This repository is a mirror of https://git.openwrt.org/?p=project/odhcpd.git. Pull requests will be accepted which will be merged in odhcpd.git
GNU General Public License v2.0
160 stars 96 forks source link

IPv4 DHCP relay master not working? #156

Closed Legogris closed 4 years ago

Legogris commented 4 years ago

I have the following setup:

1 <=> 2 <=> 3
  1. OpenWRT 19.07 running odhcpd
  2. Debian buster running isc-dhcp-relay
  3. DHCP client host

odhcpd is serving request to directly connected clients just fine.

isc-dhcp-relay is running with:

dhcrelay -d -4 -c 10 -iu enp2s0 -id enp3s0 -A 1300 -a 10.1.2.1

(where enp2s0 is connected to 1, enp3s0 is connected to 2 and 10.1.2.1 is IP of 1)

The dhcrelay log shows requests being forwarded:

Forwarded BOOTREQUEST for [MAC] to 10.1.2.1

Using tcpdump on 2, request apckets are going out but no responses are coming back:

# tcpdump -i enp2s0 -vvv -s 1500 '((port 67 or port 68))'

07:22:57.191964 IP (tos 0x0, ttl 64, id 48777, offset 0, flags [DF], proto UDP (17), length 328)
    HOSTNAME2.DOMAIN.bootps > openwrt.bootps: [bad udp cksum 0x194a -> 0xf7c7!] BOOTP/DHCP, Request from MAC3 (oui Unknown), length 300, hops 1, xid 0xb0123f54, Flags [none] (0x0000)
          Gateway-IP HOSTNAME2
          Client-Ethernet-Address MAC3 (oui Unknown)
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message Option 53, length 1: Request
            Requested-IP Option 50, length 4: HOSTNAME3
            Parameter-Request Option 55, length 7:
              Subnet-Mask, BR, Time-Zone, Default-Gateway
              Domain-Name, Domain-Name-Server, Hostname
            Agent-Information Option 82, length 8:
              Circuit-ID SubOption 1, length 6: enp3s0
            END Option 255, length 0
            PAD Option 0, length 0, occurs 31

Same on 1:

# tcpdump -i br-DOMAIN -vvv -s 1500 '((port 67 or port 68))'

07:26:30.718849 IP (tos 0x0, ttl 64, id 9672, offset 0, flags [DF], proto UDP (17), length 328)
    HOSTNAME2.DOMAIN.67 > openwrt.67: [udp sum ok] BOOTP/DHCP, Request from MAC3 (oui Unknown), length 300, hops 1, xid 0x512d9e73, secs 49, Flags [none] (0x0000)
          Gateway-IP 10.1.2.42
          Client-Ethernet-Address MAC3 (oui Unknown)
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message Option 53, length 1: Discover
            Parameter-Request Option 55, length 7:
              Subnet-Mask, BR, Time-Zone, Default-Gateway
              Domain-Name, Domain-Name-Server, Hostname
            Agent-Information Option 82, length 8:
              Circuit-ID SubOption 1, length 6: enp3s0
            END Option 255, length 0
            PAD Option 0, length 0, occurs 37

I have tried various permutations of options for dhcrelay (-a, -D, -m).

On the other hand, looking at the debug logs (loglevel 7) of odhcpd:

Tue Mar 24 07:38:36 2020 daemon.debug odhcpd[22376]: Received 300 Bytes from 10.1.2.2%DOMAIN@br-DOMAIN
Tue Mar 24 07:38:36 2020 daemon.debug odhcpd[22376]: Got DHCPv4 request on DOMAIN
Tue Mar 24 07:38:36 2020 daemon.debug odhcpd[22376]: Assigning static IP: 10.1.2.118
Tue Mar 24 07:38:36 2020 daemon.info odhcpd[22376]: Received DHCPV4_MSG_DISCOVER from MAC3 on DOMAIN
Tue Mar 24 07:38:36 2020 daemon.debug odhcpd[22376]: Sent DHCPV4_MSG_OFFER to MAC3 - 10.1.2.42
Tue Mar 24 07:38:39 2020 daemon.debug odhcpd[22376]: Received 300 Bytes from 10.1.2.2%DOMAIN@br-DOMAIN
Tue Mar 24 07:38:39 2020 daemon.debug odhcpd[22376]: Got DHCPv4 request on DOMAIN
Tue Mar 24 07:38:39 2020 daemon.info odhcpd[22376]: Received DHCPV4_MSG_REQUEST from MAC3 on DOMAIN
Tue Mar 24 07:38:39 2020 daemon.debug odhcpd[22376]: Sent DHCPV4_MSG_NAK to MAC3 - 10.1.2.42
Tue Mar 24 07:38:40 2020 daemon.debug odhcpd[22376]: Received 300 Bytes from 10.1.2.2%DOMAIN@br-DOMAIN

Here, 10.1.2.42 is the IP of the interface if 2, facing 3, and 10.1.2.118 is the IP supposed to be assigned to 3.

dedeckeh commented 4 years ago

Do you have a route on device 1 for 10.1.2.42 via device 2 ?

Legogris commented 4 years ago

Do you have a route on device 1 for 10.1.2.42 via device 2 ?

That did it - thank you so much!