Dnsmasq (DHCP) client not accepting DHCPOFFER

Hi,

Just saw this on the openwrt router with dnsmasq as dhcp server. Is this a client problem or server setting issue? the server is set with the authoritative.

Tue Aug 13 14:43:13 2024 daemon.info dnsmasq-dhcp[1]: DHCPDISCOVER(br-lan) 7c:03:ab:2b:eb:bc
Tue Aug 13 14:43:13 2024 daemon.info dnsmasq-dhcp[1]: DHCPOFFER(br-lan) 192.168.2.168 7c:03:ab:2b:eb:bc
Tue Aug 13 14:43:13 2024 daemon.info dnsmasq-dhcp[1]: DHCPDISCOVER(br-lan) 7c:03:ab:2b:eb:bc
Tue Aug 13 14:43:13 2024 daemon.info dnsmasq-dhcp[1]: DHCPOFFER(br-lan) 192.168.2.168 7c:03:ab:2b:eb:bc
Tue Aug 13 14:43:13 2024 daemon.info dnsmasq-dhcp[1]: DHCPDISCOVER(br-lan) 7c:03:ab:2b:eb:bc
Tue Aug 13 14:43:13 2024 daemon.info dnsmasq-dhcp[1]: DHCPOFFER(br-lan) 192.168.2.168 7c:03:ab:2b:eb:bc
Tue Aug 13 14:43:13 2024 daemon.info dnsmasq-dhcp[1]: DHCPDISCOVER(br-lan) 7c:03:ab:2b:eb:bc
Tue Aug 13 14:43:13 2024 daemon.info dnsmasq-dhcp[1]: DHCPOFFER(br-lan) 192.168.2.168 7c:03:ab:2b:eb:bc
Tue Aug 13 14:43:13 2024 daemon.info dnsmasq-dhcp[1]: DHCPDISCOVER(br-lan) 7c:03:ab:2b:eb:bc
Tue Aug 13 14:43:13 2024 daemon.info dnsmasq-dhcp[1]: DHCPOFFER(br-lan) 192.168.2.168 7c:03:ab:2b:eb:bc
Tue Aug 13 14:43:13 2024 daemon.info dnsmasq-dhcp[1]: DHCPREQUEST(br-lan) 192.168.2.72 7c:03:ab:2b:eb:bc
Tue Aug 13 14:43:13 2024 daemon.info dnsmasq-dhcp[1]: DHCPNAK(br-lan) 192.168.2.72 7c:03:ab:2b:eb:bc wrong server-ID

Is there another DHCP server on the network somewhere?

Please connect to your OpenWrt device using ssh and copy the output of the following commands and post it here using the "Preformatted text </> " button:
grafik
Remember to redact passwords, MAC addresses and any public IP addresses you may have:

ubus call system board
cat /etc/config/network
cat /etc/config/dhcp
1 Like
 ubus call system board
{
        "kernel": "5.15.150",
        "hostname": "AX4200",
        "system": "ARMv8 Processor rev 4",
        "model": "ASUS TUF-AX4200",
        "board_name": "asus,tuf-ax4200",
        "rootfs_type": "squashfs",
        "release": {
                "distribution": "OpenWrt",
                "version": "23.05.3",
                "revision": "r23809-234f1a2efa",
                "target": "mediatek/filogic",
                "description": "OpenWrt 23.05.3 r23809-234f1a2efa"
        }
}

cat /etc/config/network

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd05:e82a:b786::/48'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'

config device
        option name 'lan1'
        option macaddr 'c8:7f:54:27:27:be'

config device
        option name 'lan2'
        option macaddr 'c8:7f:54:27:27:be'

config device
        option name 'lan3'
        option macaddr 'c8:7f:54:27:27:be'

config device
        option name 'lan4'
        option macaddr 'c8:7f:54:27:27:be'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option ipaddr '192.168.2.1'
        option netmask '255.255.255.0'
        option ip6assign '60'

config device
        option name 'eth1'
        option macaddr 'c8:7f:54:27:27:be'

config interface 'wan'
        option device 'eth1'
        option proto 'dhcp'

config interface 'wan6'
        option device 'eth1'
        option proto 'dhcpv6'


 cat /etc/config/dhcp

config dnsmasq
        option domainneeded '1'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option cachesize '1000'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        option localservice '1'
        option ednspacket_max '1232'

config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '99'
        option leasetime '12h'
        option dhcpv4 'server'
        option dhcpv6 'server'
        option ra 'server'
        list ra_flags 'managed-config'
        list ra_flags 'other-config'
        option force '1'
        list dhcp_option '6,75.153.171.116,8.8.8.8'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'

config host
        list mac '12:46:82:13:B0:27'
        option ip '192.168.2.160'
        option leasetime '12h'

config host
        option ip '192.168.2.161'
        list mac 'CE:A9:65:0C:6A:D3'
        option leasetime '12h'

config host
        list mac '8A:4D:E0:80:54:55'
        option ip '192.168.2.120'
        option leasetime '12h'

config host
        option ip '192.168.2.167'
        list mac 'AC:D5:64:06:39:4D'
        option leasetime '12h'


Everything looks generally normal.

Remove the force from above.
Then issue this:

/etc/init.d/dnsmasq restart
logread -e udhcpc
root@AX4200:~# /etc/init.d/dnsmasq restart
udhcpc: started, v1.36.1
udhcpc: broadcasting discover
udhcpc: no lease, failing
root@AX4200:~# logread -e udhcpc
root@AX4200:~# logread -e udhcpc
root@AX4200:~#

do I need to monitor the system log for problem to show up?

This is a good sign. This seems to indicate that there is no other DHCP server on your network.

Now, with the machine that was unable to obtain a lease -- unplug the ethernet (or turn off wifi), then plug it back in (or turn on wifi) so that the network connection on that device goes down entirely and then comes back up. Then monitor the output of dnsmasq (logread -e dnsmasq-dhcp)

I have old andriod phone keep trying get an old ip. tried to disable/enable wifi, forget the network and rejoin

Tue Aug 13 20:53:23 2024 daemon.info dnsmasq-dhcp[1]: DHCPDISCOVER(br-lan) 7c:03:ab:2b:eb:bc
Tue Aug 13 20:53:23 2024 daemon.info dnsmasq-dhcp[1]: DHCPOFFER(br-lan) 192.168.2.168 7c:03:ab:2b:eb:bc
Tue Aug 13 20:53:23 2024 daemon.info dnsmasq-dhcp[1]: DHCPREQUEST(br-lan) 192.168.2.72 7c:03:ab:2b:eb:bc
Tue Aug 13 20:53:23 2024 daemon.info dnsmasq-dhcp[1]: DHCPNAK(br-lan) 192.168.2.72 7c:03:ab:2b:eb:bc wrong server-ID
Tue Aug 13 20:53:23 2024 daemon.info dnsmasq-dhcp[1]: DHCPREQUEST(br-lan) 192.168.2.72 7c:03:ab:2b:eb:bc
Tue Aug 13 20:53:23 2024 daemon.info dnsmasq-dhcp[1]: DHCPNAK(br-lan) 192.168.2.72 7c:03:ab:2b:eb:bc wrong server-ID
Tue Aug 13 20:53:23 2024 daemon.info dnsmasq-dhcp[1]: DHCPREQUEST(br-lan) 192.168.2.72 7c:03:ab:2b:eb:bc
Tue Aug 13 20:53:23 2024 daemon.info dnsmasq-dhcp[1]: DHCPNAK(br-lan) 192.168.2.72 7c:03:ab:2b:eb:bc wrong server-ID
 logread -e udhcpc
Tue Aug 13 20:36:32 2024 daemon.notice netifd: wan (2691): udhcpc: sending renew to server 192.168.1.254
Tue Aug 13 20:36:32 2024 daemon.notice netifd: wan (2691): udhcpc: lease of 192.168.1.67 obtained from 192.168.1.254, lease time 86400

Do any other system show this problem?

Please try disabling the DHCP server by adding the following line to the lan DHCP server.

        option ignore '1'

Then restart dnsmasq (/etc/init.d/dnsmasq restart). Once that is complete, repeat this:

Does the phone get an IP address?

it got an ip that is outside the dhcp scope but was able to access the internet. It was able to use 192.168.2.72 to access the internet.

Tue Aug 13 20:53:23 2024 daemon.info dnsmasq-dhcp[1]: DHCPNAK(br-lan) 192.168.2.72 7c:03:ab:2b:eb:bc wrong server-ID

It got an IP after you disabled the DHCP server on OpenWrt, correct?

That means you do have another DHCP server on your network.

it seem the client is being stubborn and insist on getting the ip it wants and ignoring the dhcp offer. It keep on requesting the same ip and the dhcp server nak it. It happens to different WIFI client on the network.

Thu Aug 15 17:46:27 2024 daemon.info dnsmasq-dhcp[1]: DHCPREQUEST(br-lan) 192.168.2.117 6c:ad:f8:ba:e9:2d
Thu Aug 15 17:46:27 2024 daemon.info dnsmasq-dhcp[1]: DHCPNAK(br-lan) 192.168.2.117 6c:ad:f8:ba:e9:2d address in use
Thu Aug 15 17:46:31 2024 daemon.info dnsmasq-dhcp[1]: DHCPDISCOVER(br-lan) 6c:ad:f8:ba:e9:2d
Thu Aug 15 17:46:31 2024 daemon.info dnsmasq-dhcp[1]: DHCPOFFER(br-lan) 192.168.2.185 6c:ad:f8:ba:e9:2d
Thu Aug 15 17:46:31 2024 daemon.info dnsmasq-dhcp[1]: DHCPREQUEST(br-lan) 192.168.2.117 6c:ad:f8:ba:e9:2d
Thu Aug 15 17:46:31 2024 daemon.info dnsmasq-dhcp[1]: DHCPNAK(br-lan) 192.168.2.117 6c:ad:f8:ba:e9:2d wrong server-ID

Did you find the rogue DHCP server on your network yet?

can I do that with any command on openwrt?

Well, what devices do you have on the network that might have an active DHCP server? There are some methods to hunt it down with packet captures and the like, but for a home network, you can probably find it by simply evaluating the devices on your network (there usually aren't that many). A PiHole, a misconfigured wifi AP, or even a Windows server could easily be culprits.

The most practical method is usually the pragmatic one: turn off the OpenWrt DHCP server, then test the ability to get a DHCP lease on a client device. Then unplug or turn off devices along the way such as APs and the like until the DHCP responses stop. The last device you unplug in this process is the one that has an active DHCP server.

Remove and re-instate wifi connection on android, it caches auth keys forever.
How old android? Say early wpa3 suppport is of better-not type on androids

cat /etc/config/wireless

Thanks all for the help! I just found my kids turn on an old router by mistake and that should be the rouge DHCP server that is causing the trouble. I removed all statis lease and everything is working now. Hope that is the source of the problem.

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.
Thanks! :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.