With logread it turns out that some 4 hours after reboot vuplus asks for a new dhcp lease. I suspect that until then the router is unable to resolve vuplus. Is there a way around this so that immediately after reboot vuplus is resolved?
The settings in both host and domain sections should match for each host.
Both sections are required since restarting the router removes the lease file.
To ensure consistency I created this sed script called joinhosts:
#!/bin/sed -nf
# Join host name and ip address in /etc/config/dhcp host records to /etc/hosts format
/^\toption name/h
/^\toption ip/{G;s/\toption ip '\(.*\)'\n\toption name '\(.*\)'/\1\t\2/;p}
is the solution to my problem! After this command added host names are resolved. No wait is needed anymore. So thank you for the link.
I find the way they retrieve the host names from uci more elegant than mine because it doesn't depend on the /etc/config/dhcp file syntax e.g. the use of single quotes which is optional.
Therefore I changed my script joinhosts like this:
#!/bin/sed -nf
# Join host name and ip address in uci host records to /etc/hosts format
/^dhcp.@host\[.*\].name=/h
/^dhcp.@host\[.*\].ip=/{G;s/^dhcp.@host\[.*\].ip='\(.*\)'\ndhcp.@host\[.*\].name='\(.*\)'/\1\t\2/;p}
I call it in /etc/rc.local like this:
uci show dhcp | /root/bin/joinhosts > /tmp/lanhosts
I simplified the sed command a bit and reduced it to one line. Now my /etc/rc.local looks like this:
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
uci show dhcp | sed -n "/@host.*name=/h;/@host.*ip=/{G;s/.*='\(.*\)'\n.*='\(.*\)'/\1\t\2/;p}" > /tmp/lanhosts
/etc/init.d/dnsmasq restart
mount -a
exit 0
to a host section in /etc/config/dhcp adds static forward and reverse DNS entries for that host. I did that for all hosts and now they are all available right after boot completes. The only command remaining in /etc/rc.local is now:
mount -a
Only one method can be the simplest and this is the one. Thanks @vgaetera !