DNSMASQ is ignoring parameters

Having the problem of not-working DHCP on my lan interface (bridge). dnsmasq is running but its not even listening on 67 port (DHCP v4). Obviously the issue comes from wrong auto-generated configuration file

/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 leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        option localservice '1'
        option ednspacket_max '1232'
        option authoritative '1'
        list interface 'lan'

config dhcp 'lan'
        option interface 'lan'
        option start '110'
        option limit '150'
        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'

config dhcp 'wan'
        option interface 'wan'

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

and the resulted generated file
/var/etc/dnsmasq.conf.cfg01411c

# auto-generated config file from /etc/config/dhcp
conf-file=/etc/dnsmasq.conf
domain-needed
localise-queries
enable-ubus=dnsmasq
expand-hosts
bind-dynamic
local-service
cache-size=1000
edns-packet-max=1232
domain=lan
local=/lan/
interface=br-lan
addn-hosts=/tmp/hosts
dhcp-leasefile=/tmp/dhcp.leases
resolv-file=/tmp/resolv.conf.d/resolv.conf.auto
stop-dns-rebind
rebind-localhost-ok
dhcp-broadcast=tag:needs-broadcast
conf-dir=/tmp/dnsmasq.d
user=dnsmasq
group=dnsmasq


dhcp-ignore-names=tag:dhcp_bogus_hostname
conf-file=/usr/share/dnsmasq/dhcpbogushostname.conf


bogus-priv
conf-file=/usr/share/dnsmasq/rfc6761.conf
no-dhcp-interface=br-lan

First question: where are all range DHCP settings

option start '110'
option limit '150'
option leasetime '12h'

Second:

Why do we have no-dhcp-interface=br-lan while having dnsmasq bound exactly to same interface
in line interface=br-lan.

Frankly speaking dont know from where did it take these 3 lines:

bogus-priv
conf-file=/usr/share/dnsmasq/rfc6761.conf
no-dhcp-interface=br-lan

/etc/dnsmasq.conf has no changes

The result of that is that dnsqmasq is not listening on udp:67 at all

  1. What is the result of the command:

ubus call system board

  1. Are these default configs?
1 Like

@lleachii

root@Master:~# ubus call system board
{
	"kernel": "5.15.132",
	"hostname": "Master",
	"system": "ARMv7 Processor rev 5 (v7l)",
	"model": "Linksys WHW01",
	"board_name": "linksys,whw01",
	"rootfs_type": "squashfs",
	"release": {
		"distribution": "OpenWrt",
		"version": "SNAPSHOT",
		"revision": "r23995-ce7209bd21",
		"target": "ipq40xx/generic",
		"description": "OpenWrt SNAPSHOT r23995-ce7209bd21"
	}
}
root@Master:~# netstat -ltun
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN
tcp        0      0 192.168.50.1:53         0.0.0.0:*               LISTEN
tcp        0      0 fd9b:12fc:8e8d::1:53    :::*                    LISTEN
tcp        0      0 fe80::3223:3ff:fe95:fa1a:53 :::*                    LISTEN
tcp        0      0 :::22                   :::*                    LISTEN
tcp        0      0 :::80                   :::*                    LISTEN
tcp        0      0 ::1:53                  :::*                    LISTEN
udp        0      0 127.0.0.1:53            0.0.0.0:*
udp        0      0 192.168.50.1:53         0.0.0.0:*
udp        0      0 ::1:53                  :::*
udp        0      0 fd9b:12fc:8e8d::1:53    :::*
udp        0      0 fe80::3223:3ff:fe95:fa1a:53 :::*

Your start and limit values are too large.110 + 150 = 260, which is greater than 255. What is the router LAN IP?

1 Like

@dave14305 thanks for pointing that out (it's a typoo when i was trying to fix the issue), edited original answer - it's not related still having same problem with start=100 and limit=150

@lleachii btw, indeed origal configs are slightly different:

/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 cachesize '1000'                                                                                                     
        option authoritative '1'                                                                                                    
        option readethers '1'                                                                                                       
        option leasefile '/tmp/dhcp.leases'                                                                                         
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'                                                                     
        option nonwildcard '1'                                                                                                      
        option localservice '1'                                                                                                     
        option ednspacket_max '1232'                                                                                                
        option filter_aaaa '0'                                                                                                      
        option filter_a '0'                                                                                                         
                                                                                                                                    
config dhcp 'lan'                                                                                                                   
        option interface 'lan'                                                                                                      
        option start '100'                                                                                                          
        option limit '150'                                                                                                          
        option leasetime '12h'                                                                                                      
        option dhcpv4 'server'                                                                                                      
        option dhcpv6 'server'                                                                                                      
        option ra 'server'                                                                                                          
        option ra_slaac '1'                                                                                                         
        list ra_flags 'managed-config'                                                                                              
        list ra_flags 'other-config'                                                                                                
                                                                                                                                    
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'           

and the resulting generated file looks "great"

# auto-generated config file from /etc/config/dhcp
conf-file=/etc/dnsmasq.conf
dhcp-authoritative
domain-needed
localise-queries
read-ethers
enable-ubus=dnsmasq
expand-hosts
bind-dynamic
local-service
cache-size=1000
edns-packet-max=1232
domain=lan
local=/lan/
addn-hosts=/tmp/hosts
dhcp-leasefile=/tmp/dhcp.leases
resolv-file=/tmp/resolv.conf.d/resolv.conf.auto
stop-dns-rebind
rebind-localhost-ok
dhcp-broadcast=tag:needs-broadcast
conf-dir=/tmp/dnsmasq.d
user=dnsmasq
group=dnsmasq


dhcp-ignore-names=tag:dhcp_bogus_hostname
conf-file=/usr/share/dnsmasq/dhcpbogushostname.conf


bogus-priv
conf-file=/usr/share/dnsmasq/rfc6761.conf
dhcp-range=set:lan,192.168.1.100,192.168.1.249,255.255.255.0,12h

The simplest way to check for something wrong is to do:
service dnsmasq restart

followed by:
logread -e dnsmasq -l 40

Post the output here.......

1 Like

@bluewavenet there is nothing valuable there. dnsmasq got SIGNT, dnsmasq started, no errors,
see above - issue is in badly generated config file which is missing the range setting

dhcp-range=set:lan,192.168.1.100,192.168.1.249,255.255.255.0,12h

I think there may be more clues in your /etc/config/network file.

You had an interface parameter set in the dnsmasq instance, and you did not have an ignore option set on the DHCP wan section. Just some additional observations…

1 Like

Ah, so you know enough to say there is nothing of value to be seen in the logs, so don't bother to show us.

It will work with default settings after reflash, so it is 100% certain you have a config problem.

Typically you will get in the logs, the following:

Fri Sep 22 13:50:43 2023 daemon.info dnsmasq[1]: exiting on receipt of SIGTERM
Fri Sep 22 13:50:47 2023 daemon.info dnsmasq[1]: started, version 2.89 cachesize 1000
Fri Sep 22 13:50:47 2023 daemon.info dnsmasq[1]: DNS service limited to local subnets
Fri Sep 22 13:50:47 2023 daemon.info dnsmasq[1]: compile time options: IPv6 GNU-getopt no-DBus UBus no-i18n no-IDN DHCP no-DHCPv6 no-Lua TFTP no-conntrack no-ipset no-nftset no-auth no-cryptohash no-DNSSEC no-ID loop-detect inotify dumpfile
Fri Sep 22 13:50:47 2023 daemon.info dnsmasq[1]: UBus support enabled: connected to system bus
Fri Sep 22 13:50:47 2023 daemon.info dnsmasq-dhcp[1]: DHCP, IP range 192.168.1.100 -- 192.168.1.249, lease time 12h

Note the last line showing the DHCP range.

If you have a config error stopping dhcp from working then this line would not be present and possibly replaced by an error.

1 Like

@bluewavenet that line is absent, and there is no error. No DHCP v4 launched, port 67 down as mentioned. Other parts of dnsmasq (like DNS) went up OK.

Then you have it disabled by some config setting.

Try:
uci set dhcp.lan.ignore='0'

Don't commit it for now.

Then do:
service dnsmasq restart
This time check the output of the restart and check the logs again.....

The restart should give:

udhcpc: started, v1.36.1
udhcpc: broadcasting discover
udhcpc: no lease, failing

The "failing" indicates dnsmasq did not find another dhcp server on the network and is what is what you want under normal circumstances.

@bluewavenet thanks, it was indeed useful

i had

option force '1'

in my

config dhcp 'lan'

removed it, and got the above output :+1:
also logread -e dnsmasq now contais the lease record.

so something is disabling dhcp on lan implicitly, though seems i do not have that setting

Most likely in your network config..
Show the output of:
uci export network

@bluewavenet hmm...

root@Master:~# uci export network
package 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 'fd9b:12fc:8e8d::/48'

config device
	option name 'br-lan'
	option type 'bridge'
	list ports 'eth2'

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

config interface 'wan'
	option proto 'pppoe'
	option device 'eth1.30'
	option username 'blablabla'
	option password 'blablabla'
	option ipv6 'auto'

config device
	option name 'eth1'
	option macaddr 'c4:e5:32:0c:45:88'

config device
	option type '8021q'
	option ifname 'eth1'
	option vid '30'
	option name 'eth1.30'

This is invalid in the network config.
I think it should be:
option device 'eth1'

I don't know if this causing the problem, but it will be causing issues somewhere.

Do you mean it works now?

This is invalid in the network config.
I think it should be:
option device 'eth1'

Are you sure about it? Here https://openwrt.org/docs/guide-user/base-system/basic-networking
it's written that "fname@interface has been moved to device and device sections (it's device section, not interface section) :thinking:

No, unfortunately after reboot something makes dhcp.lan.ignore = '1'

P.S.: as a side note, figured out that LUCI wipes out a bunch of default parameters from /etc/config/dhcp (just pressing SAVE wiithout any changes rewrites them):
option boguspriv '1'
option filterwin2k '0'
option nonegcache '0'
option nonwildcard '1'
option filter_aaaa '0'
option filter_a '0'

is it possible to put them into some more protected place?
update:forget about those, they are default values and luci just removes them

For clarity, what is the current config? Getting confused…

uci export dhcp

after reboot
uci export dhcp

package 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 readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
	option localservice '1'
	option ednspacket_max '1232'
	option authoritative '0'

config dhcp 'lan'
	option interface 'lan'
	option start '100'
	option limit '150'
	option leasetime '12h'
	option dhcpv4 'server'
	option dhcpv6 'server'
	option ra 'server'
	option ignore '1'
	list ra_flags 'managed-config'
	list ra_flags 'other-config'

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'

but
cat /etc/config/dhcp

root@Master:~# 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 readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
	option localservice '1'
	option ednspacket_max '1232'
	option authoritative '1'

config dhcp 'lan'
	option interface 'lan'
	option start '100'
	option limit '150'
	option leasetime '12h'
	option dhcpv4 'server'
	option dhcpv6 'server'
	option ra 'server'
	option ignore '0'
	list ra_flags 'managed-config'
	list ra_flags 'other-config'

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'

notice that dhcp.lan.ignore is overridden to '1' by someth

Yes. The user guide warning at the top is badly worded.
"ifname" is not valid anywhere in the network config.
It might appear to work but the results could be very unexpected.

Show the output of:
ip addr