No IP via DHCP until dnsmasq restart

Having a similiar issues like this one:

Manual IP configured on client works.

 OpenWrt 19.07.3, r11063-85e04e9f46
 -----------------------------------------------------
root@OpenWrt:~# cat /etc/config/network

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

config globals 'globals'
	option ula_prefix 'fd31:5a58:6752::/48'

config interface 'lan'
	option type 'bridge'
	option ifname 'eth1'
	option proto 'static'
	option force_link '1'
	option netmask '255.255.255.0'
	option ip6assign '60'
	option ipaddr '192.168.5.1'

config interface 'wan'
	option proto 'dhcp'
	option ifname 'eth2'

config interface 'WAN2'
	option ifname 'eth0'
	option proto 'dhcp'
root@OpenWrt:~# cat /etc/config/wireless

config wifi-device 'radio0'
	option type 'mac80211'
	option channel '11'
	option hwmode '11g'
	option path 'platform/ar934x_wmac'
	option htmode 'HT20'
	option txpower '20'

config wifi-iface 'wifinet0'
	option ssid 'Limo'
	option encryption 'psk2'
	option device 'radio0'
	option mode 'ap'
	option network 'lan'
	option key '**'
root@OpenWrt:~# cat /etc/config/dhcp

config dnsmasq
	option domainneeded '1'
	option boguspriv '1'
	option filterwin2k '0'
	option localise_queries '1'
	option rebind_protection '1'
	option rebind_localhost '1'
	option local '/lan/'
	option domain 'lan'
	option expandhosts '1'
	option nonegcache '0'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option resolvfile '/tmp/resolv.conf.auto'
	option nonwildcard '1'
	option localservice '1'

config dhcp 'lan'
	option interface 'lan'
	option start '100'
	option limit '150'
	option leasetime '12h'

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'
root@OpenWrt:~# cat /etc/config/firewall

config defaults
	option syn_flood '1'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'REJECT'

config zone
	option name 'lan'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'ACCEPT'
	option network 'lan'

config zone
	option name 'wan'
	option input 'REJECT'
	option output 'ACCEPT'
	option forward 'REJECT'
	option masq '1'
	option mtu_fix '1'
	option network 'wan WAN2'

config forwarding
	option src 'lan'
	option dest 'wan'

config rule
	option name 'Allow-DHCP-Renew'
	option src 'wan'
	option proto 'udp'
	option dest_port '68'
	option target 'ACCEPT'
	option family 'ipv4'

config rule
	option name 'Allow-Ping'
	option src 'wan'
	option proto 'icmp'
	option icmp_type 'echo-request'
	option family 'ipv4'
	option target 'ACCEPT'

config rule
	option name 'Allow-IGMP'
	option src 'wan'
	option proto 'igmp'
	option family 'ipv4'
	option target 'ACCEPT'

config rule
	option name 'Allow-DHCPv6'
	option src 'wan'
	option proto 'udp'
	option src_ip 'fc00::/6'
	option dest_ip 'fc00::/6'
	option dest_port '546'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-MLD'
	option src 'wan'
	option proto 'icmp'
	option src_ip 'fe80::/10'
	list icmp_type '130/0'
	list icmp_type '131/0'
	list icmp_type '132/0'
	list icmp_type '143/0'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-ICMPv6-Input'
	option src 'wan'
	option proto 'icmp'
	list icmp_type 'echo-request'
	list icmp_type 'echo-reply'
	list icmp_type 'destination-unreachable'
	list icmp_type 'packet-too-big'
	list icmp_type 'time-exceeded'
	list icmp_type 'bad-header'
	list icmp_type 'unknown-header-type'
	list icmp_type 'router-solicitation'
	list icmp_type 'neighbour-solicitation'
	list icmp_type 'router-advertisement'
	list icmp_type 'neighbour-advertisement'
	option limit '1000/sec'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-ICMPv6-Forward'
	option src 'wan'
	option dest '*'
	option proto 'icmp'
	list icmp_type 'echo-request'
	list icmp_type 'echo-reply'
	list icmp_type 'destination-unreachable'
	list icmp_type 'packet-too-big'
	list icmp_type 'time-exceeded'
	list icmp_type 'bad-header'
	list icmp_type 'unknown-header-type'
	option limit '1000/sec'
	option family 'ipv6'
	option target 'ACCEPT'

config rule
	option name 'Allow-IPSec-ESP'
	option src 'wan'
	option dest 'lan'
	option proto 'esp'
	option target 'ACCEPT'

config rule
	option name 'Allow-ISAKMP'
	option src 'wan'
	option dest 'lan'
	option dest_port '500'
	option proto 'udp'
	option target 'ACCEPT'

config include
	option path '/etc/firewall.user'
1 Like

@mstaack, welcome to thecommunity!

Can you describe your exact issue?

Yeah so I connect via WiFi. I get an ipv6 address but no ipv4 address. Same for lan cable connection. But when I issue a dnsmasq restart it all starts to work fine.

Could it be some kind of race condition?

Cheers Max

Is there anything in the logs regarding dnsmasq right after the reboot?
logread -e dnsmasq

i noticed i get a ipv4 address for a second.. then its gone...

root@OpenWrt:~# logread -e dnsmasq
Wed Jul  1 17:11:18 2020 user.notice dnsmasq: DNS rebinding protection is active, will discard upstream RFC1918 responses!
Wed Jul  1 17:11:18 2020 user.notice dnsmasq: Allowing 127.0.0.0/8 responses
Wed Jul  1 17:11:19 2020 daemon.info dnsmasq[799]: started, version 2.80 cachesize 150
Wed Jul  1 17:11:19 2020 daemon.info dnsmasq[799]: DNS service limited to local subnets
Wed Jul  1 17:11:19 2020 daemon.info dnsmasq[799]: compile time options: IPv6 GNU-getopt no-DBus no-i18n no-IDN DHCP no-DHCPv6 no-Lua TFTP no-conntrack no-ipset no-auth no-DNSSEC no-ID loop-detect inotify dumpfile
Wed Jul  1 17:11:19 2020 daemon.info dnsmasq[799]: using local addresses only for domain test
Wed Jul  1 17:11:19 2020 daemon.info dnsmasq[799]: using local addresses only for domain onion
Wed Jul  1 17:11:19 2020 daemon.info dnsmasq[799]: using local addresses only for domain localhost
Wed Jul  1 17:11:19 2020 daemon.info dnsmasq[799]: using local addresses only for domain local
Wed Jul  1 17:11:19 2020 daemon.info dnsmasq[799]: using local addresses only for domain invalid
Wed Jul  1 17:11:19 2020 daemon.info dnsmasq[799]: using local addresses only for domain bind
Wed Jul  1 17:11:19 2020 daemon.info dnsmasq[799]: using local addresses only for domain lan
Wed Jul  1 17:11:19 2020 daemon.warn dnsmasq[799]: no servers found in /tmp/resolv.conf.auto, will retry
Wed Jul  1 17:11:19 2020 daemon.info dnsmasq[799]: read /etc/hosts - 4 addresses
Wed Jul  1 17:11:19 2020 daemon.info dnsmasq[799]: read /tmp/hosts/dhcp.cfg01411c - 0 addresses
Wed Jul  1 17:11:30 2020 daemon.info dnsmasq[799]: read /etc/hosts - 4 addresses
Wed Jul  1 17:11:30 2020 daemon.info dnsmasq[799]: read /tmp/hosts/dhcp.cfg01411c - 0 addresses
root@OpenWrt:~#

this entry seems suspicious:
Wed Jul 1 17:11:19 2020 daemon.warn dnsmasq[799]: no servers found in /tmp/resolv.conf.auto, will retry

also one note...i use a 4g lte stick as wan/uplink... which takes a minute or so to enumerate... might be this an issue?

That is a warning, should not be a reason to crash the dnsmasq.
Can you verify if the dnsmasq is running after you reboot?

ps wwww | grep -i dnsmasq
netstat -lnp | grep -i dnsmasq

its running:

root@OpenWrt:~# ps wwww | grep -i dnsmasq
  798 dnsmasq   1344 S    /usr/sbin/dnsmasq -C /var/etc/dnsmasq.conf.cfg01411c -k -x /var/run/dnsmasq/dnsmasq.cfg01411c.pid
 1446 root      1216 S    grep -i dnsmasq
root@OpenWrt:~# netstat -lnp | grep -i dnsmasq
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      798/dnsmasq
tcp        0      0 192.168.5.1:53          0.0.0.0:*               LISTEN      798/dnsmasq
tcp        0      0 fd31:5a58:6752::1:53    :::*                    LISTEN      798/dnsmasq
tcp        0      0 fe80::ce2d:e0ff:fe12:dfa7:53 :::*                    LISTEN      798/dnsmasq
tcp        0      0 fe80::ce2d:e0ff:fe12:dfb1:53 :::*                    LISTEN      798/dnsmasq
tcp        0      0 ::1:53                  :::*                    LISTEN      798/dnsmasq
udp        0      0 127.0.0.1:53            0.0.0.0:*                           798/dnsmasq
udp        0      0 192.168.5.1:53          0.0.0.0:*                           798/dnsmasq
udp        0      0 fd31:5a58:6752::1:53    :::*                                798/dnsmasq
udp        0      0 fe80::ce2d:e0ff:fe12:dfa7:53 :::*                                798/dnsmasq
udp        0      0 fe80::ce2d:e0ff:fe12:dfb1:53 :::*                                798/dnsmasq
udp        0      0 ::1:53                  :::*                                798/dnsmasq

but not listening to udp/67 for dhcps.
Try to add some custom DNS in the wwan connection, e.g 8.8.8.8 , 1.1.1.1, 9.9.9.9 and try once more.

Also what is the output of:

ls -l  /etc/resolv.* /tmp/resolv.*; head -n -0 /etc/resolv.* /tmp/resolv.*
1 Like

ahhhh brilliant! adding custom dns to the WAN interface solved the issue!:

port 67 is there and i get normal ip address via dhcp! thank you a lot!

root@OpenWrt:~# netstat -lnp | grep -i dnsmasq
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      1444/dnsmasq
tcp        0      0 192.168.5.1:53          0.0.0.0:*               LISTEN      1444/dnsmasq
tcp        0      0 fe80::ce2d:e0ff:fe12:dfb1:53 :::*                    LISTEN      1444/dnsmasq
tcp        0      0 ::1:53                  :::*                    LISTEN      1444/dnsmasq
tcp        0      0 fd31:5a58:6752::1:53    :::*                    LISTEN      1444/dnsmasq
tcp        0      0 fe80::ce2d:e0ff:fe12:dfa7:53 :::*                    LISTEN      1444/dnsmasq
udp        0      0 127.0.0.1:53            0.0.0.0:*                           1444/dnsmasq
udp        0      0 192.168.5.1:53          0.0.0.0:*                           1444/dnsmasq
udp        0      0 0.0.0.0:67              0.0.0.0:*                           1444/dnsmasq
udp        0      0 fe80::ce2d:e0ff:fe12:dfb1:53 :::*                                1444/dnsmasq
udp        0      0 ::1:53                  :::*                                1444/dnsmasq
udp        0      0 fd31:5a58:6752::1:53    :::*                                1444/dnsmasq
udp        0      0 fe80::ce2d:e0ff:fe12:dfa7:53 :::*                                1444/dnsmasq

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.

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