Script to run on first boot (uci-defaults) for unbound

uci set unbound.@unbound[0].dhcp_link="dnsmasq"
uci set unbound.@unbound[0].domain="lan"
uci set unbound.@unbound[0].listen_port="53"
uci commit unbound
service unbound restart
uci set dhcp.dnsmasq.domain="lan"
uci set dhcp.dnsmasq.noresolv="1"
uci set dhcp.dnsmasq.port="1053"
uci set dhcp.dnsmasq.resolvfile="/tmp/resolv.conf.auto"
uci set dhcp.lan.dhcp_option="option:dns-server,0.0.0.0"
uci commit dhcp
service dnsmasq restart

Can everyone help me see what is wrong that causes the script not to work?

Port 53 in use by dnsmasq on the restart of unbound?

When restarting, unbound loses port 53 rights, right?

That is what you want, but it appears you are bouncing the unbound service while dnsmasq is still there.

So I have to move the dnsmasq command first and then unbound?

You could do service dnsmasq stop 1st.

1 Like

Yes, I should run dnsmasq first then unbound unlike odhcpd. I confused odhcpd with dnsmasq!