I have installed OpenWrt 19.07.3 in Mikrotik RouterBoard RB750-r2. Using 'dhcp' proto on the wan port does not work properly. If I use another OpenWrt as the upstream router then it receives and sets IPv4 address to the wan port properly.
But when I connect the WAN port of the OpenWrt to the LAN of a Tenda router (active in my house) it (OpenWrt) cannot set the IP address. It seems udhcpc ignores dhcp offers from the Tenda router.
I ran the following commands:
reset; \
NET_IF="wan"; \
NET_DEV="$(uci get network.${NET_IF}.ifname)"; \
ifup "${NET_IF}"; sleep 10; \
tcpdump -v -n -i "${NET_DEV}" udp port 67 or udp port 68 & \
ip address show dev "${NET_DEV}"; \
kill -SIGUSR2 "$(pidof udhcpc)"; sleep 10; \
ip address show dev "${NET_DEV}"; \
kill -SIGUSR1 "$(pidof udhcpc)"; sleep 10; \
ip address show dev "${NET_DEV}"; \
killall tcpdump
and got the following output:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP100> mtu 1500 qdisc fq_codel state UP qlen 1000
link/ether cc:2d:e0:69:32:e0 brd ff:ff:ff:ff:ff:ff
inet6 fe80::ce2d:e0ff:fe69:32e0/64 scope link
valid_lft forever preferred_lft forever
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP100> mtu 1500 qdisc fq_codel state UP qlen 1000
link/ether cc:2d:e0:69:32:e0 brd ff:ff:ff:ff:ff:ff
inet6 fe80::ce2d:e0ff:fe69:32e0/64 scope link
valid_lft forever preferred_lft forever
18:34:41.986525 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 328)
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from cc:2d:e0:69:32:e0, length 300, xid 0x5675a9b2, Flags [none]
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Discover
MSZ Option 57, length 2: 576
Parameter-Request Option 55, length 8:
Subnet-Mask, Default-Gateway, Domain-Name-Server, Hostname
Domain-Name, BR, NTP, Classless-Static-Route
Vendor-Class Option 60, length 12: "udhcp 1.30.1"
Hostname Option 12, length 7: "OpenWrt"
18:34:41.987144 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 328)
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from cc:2d:e0:69:32:e0, length 300, xid 0x2f5826d, Flags [none]
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Discover
Client-ID Option 61, length 7: ether cc:2d:e0:69:32:e0
Requested-IP Option 50, length 4: 192.168.1.120
MSZ Option 57, length 2: 576
Parameter-Request Option 55, length 7:
Subnet-Mask, Default-Gateway, Domain-Name-Server, Hostname
Domain-Name, BR, NTP
Vendor-Class Option 60, length 12: "udhcp 1.30.1"
18:34:42.982658 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 768)
192.168.0.1.67 > 255.255.255.255.68: BOOTP/DHCP, Reply, length 740, xid 0x5675a9b2, Flags [none]
Your-IP 192.168.0.107
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Offer
Server-ID Option 54, length 4: 192.168.0.1
Lease-Time Option 51, length 4: 48
Subnet-Mask Option 1, length 4: 255.255.255.0
Default-Gateway Option 3, length 4: 192.168.0.1
Domain-Name-Server Option 6, length 4: 192.168.0.1
Domain-Name Option 15, length 17: "www.tendawifi.com"
18:34:43.984307 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 768)
192.168.0.1.67 > 255.255.255.255.68: BOOTP/DHCP, Reply, length 740, xid 0x2f5826d, Flags [none]
Your-IP 192.168.0.107
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Offer
Server-ID Option 54, length 4: 192.168.0.1
Lease-Time Option 51, length 4: 59
Subnet-Mask Option 1, length 4: 255.255.255.0
Default-Gateway Option 3, length 4: 192.168.0.1
Domain-Name-Server Option 6, length 4: 192.168.0.1
Domain-Name Option 15, length 17: "www.tendawifi.com"
18:34:44.986340 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 328)
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from cc:2d:e0:69:32:e0, length 300, xid 0x2f5826d, secs 3, Flags [none]
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Discover
Client-ID Option 61, length 7: ether cc:2d:e0:69:32:e0
Requested-IP Option 50, length 4: 192.168.1.120
MSZ Option 57, length 2: 576
Parameter-Request Option 55, length 7:
Subnet-Mask, Default-Gateway, Domain-Name-Server, Hostname
Domain-Name, BR, NTP
Vendor-Class Option 60, length 12: "udhcp 1.30.1"
18:34:44.986755 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 328)
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from cc:2d:e0:69:32:e0, length 300, xid 0x5675a9b2, secs 3, Flags [none]
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Discover
MSZ Option 57, length 2: 576
Parameter-Request Option 55, length 8:
Subnet-Mask, Default-Gateway, Domain-Name-Server, Hostname
Domain-Name, BR, NTP, Classless-Static-Route
Vendor-Class Option 60, length 12: "udhcp 1.30.1"
Hostname Option 12, length 7: "OpenWrt"
18:34:45.979429 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 768)
192.168.0.1.67 > 255.255.255.255.68: BOOTP/DHCP, Reply, length 740, xid 0x2f5826d, Flags [none]
Your-IP 192.168.0.107
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Offer
Server-ID Option 54, length 4: 192.168.0.1
Lease-Time Option 51, length 4: 58
Subnet-Mask Option 1, length 4: 255.255.255.0
Default-Gateway Option 3, length 4: 192.168.0.1
Domain-Name-Server Option 6, length 4: 192.168.0.1
Domain-Name Option 15, length 17: "www.tendawifi.com"
18:34:46.972516 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 768)
192.168.0.1.67 > 255.255.255.255.68: BOOTP/DHCP, Reply, length 740, xid 0x5675a9b2, Flags [none]
Your-IP 192.168.0.107
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Offer
Server-ID Option 54, length 4: 192.168.0.1
Lease-Time Option 51, length 4: 59
Subnet-Mask Option 1, length 4: 255.255.255.0
Default-Gateway Option 3, length 4: 192.168.0.1
Domain-Name-Server Option 6, length 4: 192.168.0.1
Domain-Name Option 15, length 17: "www.tendawifi.com"
18:34:47.974494 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 328)
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from cc:2d:e0:69:32:e0, length 300, xid 0x2f5826d, secs 6, Flags [none]
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Discover
Client-ID Option 61, length 7: ether cc:2d:e0:69:32:e0
Requested-IP Option 50, length 4: 192.168.1.120
MSZ Option 57, length 2: 576
Parameter-Request Option 55, length 7:
Subnet-Mask, Default-Gateway, Domain-Name-Server, Hostname
Domain-Name, BR, NTP
Vendor-Class Option 60, length 12: "udhcp 1.30.1"
18:34:47.974948 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 328)
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from cc:2d:e0:69:32:e0, length 300, xid 0x5675a9b2, secs 6, Flags [none]
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Discover
MSZ Option 57, length 2: 576
Parameter-Request Option 55, length 8:
Subnet-Mask, Default-Gateway, Domain-Name-Server, Hostname
Domain-Name, BR, NTP, Classless-Static-Route
Vendor-Class Option 60, length 12: "udhcp 1.30.1"
Hostname Option 12, length 7: "OpenWrt"
18:34:48.972408 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 768)
192.168.0.1.67 > 255.255.255.255.68: BOOTP/DHCP, Reply, length 740, xid 0x2f5826d, Flags [none]
Your-IP 192.168.0.107
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Offer
Server-ID Option 54, length 4: 192.168.0.1
Lease-Time Option 51, length 4: 58
Subnet-Mask Option 1, length 4: 255.255.255.0
Default-Gateway Option 3, length 4: 192.168.0.1
Domain-Name-Server Option 6, length 4: 192.168.0.1
Domain-Name Option 15, length 17: "www.tendawifi.com"
18:34:49.972470 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 768)
192.168.0.1.67 > 255.255.255.255.68: BOOTP/DHCP, Reply, length 740, xid 0x5675a9b2, Flags [none]
Your-IP 192.168.0.107
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Offer
Server-ID Option 54, length 4: 192.168.0.1
Lease-Time Option 51, length 4: 59
Subnet-Mask Option 1, length 4: 255.255.255.0
Default-Gateway Option 3, length 4: 192.168.0.1
Domain-Name-Server Option 6, length 4: 192.168.0.1
Domain-Name Option 15, length 17: "www.tendawifi.com"
18:34:50.975076 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 328)
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from cc:2d:e0:69:32:e0, length 300, xid 0x5675a9b2, secs 9, Flags [none]
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Discover
MSZ Option 57, length 2: 576
Parameter-Request Option 55, length 8:
Subnet-Mask, Default-Gateway, Domain-Name-Server, Hostname
Domain-Name, BR, NTP, Classless-Static-Route
Vendor-Class Option 60, length 12: "udhcp 1.30.1"
Hostname Option 12, length 7: "OpenWrt"
18:34:50.976844 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 768)
192.168.0.1.67 > 255.255.255.255.68: BOOTP/DHCP, Reply, length 740, xid 0x5675a9b2, Flags [none]
Your-IP 192.168.0.107
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Offer
Server-ID Option 54, length 4: 192.168.0.1
Lease-Time Option 51, length 4: 59
Subnet-Mask Option 1, length 4: 255.255.255.0
Default-Gateway Option 3, length 4: 192.168.0.1
Domain-Name-Server Option 6, length 4: 192.168.0.1
Domain-Name Option 15, length 17: "www.tendawifi.com"
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP100> mtu 1500 qdisc fq_codel state UP qlen 1000
link/ether cc:2d:e0:69:32:e0 brd ff:ff:ff:ff:ff:ff
inet6 fe80::ce2d:e0ff:fe69:32e0/64 scope link
valid_lft forever preferred_lft forever
14 packets captured
14 packets received by filter
0 packets dropped by kernel
[1]+ Done tcpdump -v -n -i "${NET_DEV}" udp port 67 or udp port 68
Edit:
Output of the same command using an OpenWrt router as upstream:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP qlen 1000
link/ether cc:2d:e0:69:32:e0 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.120/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::ce2d:e0ff:fe69:32e0/64 scope link
valid_lft forever preferred_lft forever
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
09:16:28.270475 IP (tos 0x0, ttl 64, id 46849, offset 0, flags [DF], proto UDP (17), length 328)
192.168.1.120.68 > 192.168.1.1.67: BOOTP/DHCP, Request from cc:2d:e0:69:32:e0, length 300, xid 0x59b2fa68, secs 10, Flags [none]
Client-IP 192.168.1.120
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Release
Server-ID Option 54, length 4: 192.168.1.1
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP qlen 1000
link/ether cc:2d:e0:69:32:e0 brd ff:ff:ff:ff:ff:ff
inet6 fe80::ce2d:e0ff:fe69:32e0/64 scope link
valid_lft forever preferred_lft forever
09:16:38.309427 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 328)
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from cc:2d:e0:69:32:e0, length 300, xid 0x661e2c41, Flags [none]
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Discover
Requested-IP Option 50, length 4: 192.168.1.120
MSZ Option 57, length 2: 576
Parameter-Request Option 55, length 8:
Subnet-Mask, Default-Gateway, Domain-Name-Server, Hostname
Domain-Name, BR, NTP, Classless-Static-Route
Vendor-Class Option 60, length 12: "udhcp 1.30.1"
Hostname Option 12, length 7: "OpenWrt"
09:16:38.311421 IP (tos 0x0, ttl 64, id 25537, offset 0, flags [none], proto UDP (17), length 328)
192.168.1.1.67 > 192.168.1.120.68: BOOTP/DHCP, Reply, length 300, xid 0x661e2c41, Flags [none]
Your-IP 192.168.1.120
Server-IP 192.168.1.1
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Offer
Server-ID Option 54, length 4: 192.168.1.1
Lease-Time Option 51, length 4: 43200
RN Option 58, length 4: 21600
RB Option 59, length 4: 37800
Subnet-Mask Option 1, length 4: 255.255.255.0
BR Option 28, length 4: 192.168.1.255
Default-Gateway Option 3, length 4: 192.168.1.1
Domain-Name-Server Option 6, length 4: 192.168.1.1
Domain-Name Option 15, length 3: "lan"
09:16:38.313418 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 328)
0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from cc:2d:e0:69:32:e0, length 300, xid 0x661e2c41, Flags [none]
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Request
Requested-IP Option 50, length 4: 192.168.1.120
Server-ID Option 54, length 4: 192.168.1.1
MSZ Option 57, length 2: 576
Parameter-Request Option 55, length 8:
Subnet-Mask, Default-Gateway, Domain-Name-Server, Hostname
Domain-Name, BR, NTP, Classless-Static-Route
Vendor-Class Option 60, length 12: "udhcp 1.30.1"
Hostname Option 12, length 7: "OpenWrt"
09:16:38.316374 IP (tos 0x0, ttl 64, id 25538, offset 0, flags [none], proto UDP (17), length 334)
192.168.1.1.67 > 192.168.1.120.68: BOOTP/DHCP, Reply, length 306, xid 0x661e2c41, Flags [none]
Your-IP 192.168.1.120
Server-IP 192.168.1.1
Client-Ethernet-Address cc:2d:e0:69:32:e0
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: ACK
Server-ID Option 54, length 4: 192.168.1.1
Lease-Time Option 51, length 4: 43200
RN Option 58, length 4: 21600
RB Option 59, length 4: 37800
Subnet-Mask Option 1, length 4: 255.255.255.0
BR Option 28, length 4: 192.168.1.255
Default-Gateway Option 3, length 4: 192.168.1.1
Domain-Name-Server Option 6, length 4: 192.168.1.1
Domain-Name Option 15, length 3: "lan"
Hostname Option 12, length 7: "OpenWrt"
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP qlen 1000
link/ether cc:2d:e0:69:32:e0 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.120/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::ce2d:e0ff:fe69:32e0/64 scope link
valid_lft forever preferred_lft forever
5 packets captured
5 packets received by filter
0 packets dropped by kernel
[1]- Done tcpdump -v -n -i "${NET_DEV}" udp port 67 or udp port 68
It seems that the format/contents of the DHCP-offer message of Tenda is different from that of OpenWrt.
Note: The OpenWrt (testing router) is configured to use 192.168.10.0/24
subnet because upstream uses the default.