/etc/config/dhcp modified and dnsmasq crashed after reboot

I have a network setting in /etc/config/network:

config interface 'VDC_int'
        option proto 'static'
        option netmask '255.255.255.0'
        option device 'eth0.2'
        option ipaddr '192.168.110.252'

This network segment also DHCP enabled and the related config in /etc/config/dhcp:

config dhcp 'VDC_int'
        option leasetime '12h'
        option interface 'VDC_int'
        option start '200'
        option limit '249'
        list dhcp_option '3,192.168.110.4'
        list dhcp_option '6,192.168.110.250'

However, when I reboot the system, the dhcp_option 3 of that network becomes blank, like this

config dhcp 'VDC_int'
        option leasetime '12h'
        option interface 'VDC_int'
        option start '200'
        option limit '249'
        list dhcp_option '3,'
        list dhcp_option '6,192.168.110.250'

With that modification after reboot, it crashes the dnsmasq configuration as it creates syntax error in the generated dnsmasq.conf, and eventually the dnsmasq service cannot be started after reboot.

I notice that if I add the

option gateway 192.168.110.4

to the configuration segment in /etc/config/network, the dhcp_option can be retained against reboot, But it will force my router to use it as the default gateway and it is not my desired setting. Furthermore, In the same system, I have another networks without the gateway option in /etc/config/network which can retain the dhcp_option 3 at /etc/config/dhcp from reboot.

I have no clues why only the dhcp_option 3 of the mentioned network got removed in the /etc/config/dhcp file after reboot but the others are conserved.

Try fixing your limit... it's invalid for a /24. The limit is the size of the DHCP pool (number of addresses), not the end of the pool. Therefore, if you want to serve 200 - 249, your limit should be 50.

See if that fixes your problem. If not, let's see the complete network and dhcp files.

2 Likes

Thanks for your correction on the "limit" option. However, the problem still occurs.
Here is the /etc/config/network file:

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

config interface 'VDC_backbone'
        option proto 'static'
        option netmask '255.255.255.240'
        option device 'eth0'
        option ipaddr '192.168.98.30'
        option mtu '9000'

config interface 'VDC_loopback'
        option proto 'static'
        option netmask '255.255.255.255'
        option device '@VDC_backbone'
        option ipaddr '192.168.99.29'

config interface 'VDC_int'
        option proto 'static'
        option netmask '255.255.255.0'
        option device 'eth0.2'
        option ipaddr '192.168.110.252'

config interface 'LAN_ovpn'
        option stp '1'
        option delegate '0'
        option proto 'none'
        option device 'br-LAN_ovpn'

config interface 'DMZ1'
        option proto 'static'
        option netmask '255.255.255.240'
        option device 'eth1'
        option ipaddr '192.168.112.12'
        option mtu '9000'

config interface 'DMZ2'
        option proto 'static'
        option netmask '255.255.255.240'
        option device 'eth2'
        option ipaddr '192.168.112.28'
        option mtu '9000'

config interface 'DMZ3'
        option proto 'static'
        option netmask '255.255.255.240'
        option device 'eth3'
        option ipaddr '192.168.112.44'
        option mtu '9000'

config interface 'DMZ4'
        option proto 'static'
        option netmask '255.255.255.240'
        option device 'eth4'
        option ipaddr '192.168.112.60'
        option mtu '9000'

config device
        option name 'br-LAN_ovpn'
        option type 'bridge'
        list ports 'eth0.100'

config interface 'TUN0'
        option device 'tun0'
        option ifname 'tun0'
        option proto 'none'

config interface 'TUN1'
        option device 'tun1'
        option ifname 'tun1'
        option proto 'none'

and here is the /etc/config/dhcp file (static host setting removed)

config dnsmasq
        option domainneeded '1'
        option localise_queries '1'
        option expandhosts '1'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        option rebind_protection '0'
        option ednspacket_max '1232'
        option domain 'local'
        option allservers '1'
        option nonegcache '1'
        option local '/local/'
        option filterwin2k '1'
        list addnhosts '/etc/dnsmasq/hosts'
        list addnhosts '/etc/dnsmasq/alias'
        option nonwildcard '0'
        list server '1.1.1.1'
        list server '8.8.8.8'
        option localservice '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'

config dhcp 'VDC_int'
        option leasetime '12h'
        option interface 'VDC_int'
        option start '200'
        option limit '50'
        list dhcp_option '3,192.168.110.4'
        list dhcp_option '6,192.168.110.250'

config dhcp 'DMZ1'
        option leasetime '12h'
        option interface 'DMZ1'
        option start '0'
        option limit '0'
        option dynamicdhcp '0'
        list dhcp_option '3,192.168.112.14'
        list dhcp_option '6,192.168.112.14'

config dhcp 'DMZ2'
        option leasetime '12h'
        option interface 'DMZ2'
        option start '0'
        option limit '0'
        list dhcp_option '3,192.168.112.30'
        list dhcp_option '6,1.1.1.1,8.8.8.8'

config dhcp 'DMZ3'
        option leasetime '12h'
        option interface 'DMZ3'
        option start '0'
        list dhcp_option '3,192.168.112.46'
        list dhcp_option '6,192.168.112.46'
        option limit '0'
        option dynamicdhcp '0'

config dhcp 'DMZ4'
        option leasetime '12h'
        option interface 'DMZ4'
        option start '54'
        option limit '6'
        list dhcp_option '3,192.168.112.62'
        list dhcp_option '6,192.168.112.62'

These all have invalid start and limit values.

1 Like

Thanks for pointing it out, but it doesn't solve the problem after correction.

You need to analyze the relevant service log:
https://openwrt.org/docs/guide-user/base-system/log.essentials

1 Like

Is there any custom script updating this option?

grep -R dhcp_option /etc

You can ignore dnsmasq and S19dnsmasq in the output.