There is strange logic by generating /etc/resolv.conf (resp. /tmp/resolv.conf) file which is used by local applications. There is no difference if I put localuse '0', cachelocal '0' or port '0' to main config dnsmasq section. File /etc/resolv.conf always contains only local DNS server:
search lan
nameserver 127.0.0.1
nameserver ::1
Contents of this file will change only if I put additional option resolvfile or replace default one. It is enough to use existing empty file and then I finally get data provided to wan interface by dhcp protocol there.
I would also check whether there is more than one dnsmasq section in /etc/config/dhcp, as dave14305 hints. If one instance still has localuse enabled, /tmp/resolv.conf can still be rebuilt with loopback nameservers. The quick sanity check is uci show dhcp | grep localuse, then restart dnsmasq and look at /tmp/resolv.conf again rather than only /etc/resolv.conf, since the latter is usually just the symlink the local tools read.
I've got it on default config file /etc/config/dhcp from dnsmasq-full package. 1 instance no other modifications I had described in first message. I see big problem for ex. when I put port=0 there. So apk and other applications don't work anymore because resolv.conf contains only non existing local dns server.
config dnsmasq
option domainneeded 1
option boguspriv 1
option filterwin2k 0 # enable for dial on demand
option localise_queries 1
option rebind_protection 1 # disable if upstream must serve RFC1918 addresses
option rebind_localhost 1 # enable for RBL checking and similar services
#list rebind_domain example.lan # whitelist RFC1918 responses for domains
option local '/pt.lan/'
option domain 'pt.lan'
list server '/pt.lan/192.168.2.1'
list server '/*/192.168.2.1'
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'
#list server '/mycompany.local/1.2.3.4'
option nonwildcard 1 # bind to & keep track of interfaces
#list interface br-lan
#list notinterface lo
#list bogusnxdomain '64.94.110.11'
option localservice 1 # disable to allow DNS requests from non-local subnets
option ednspacket_max 1232
option filter_aaaa 0
option filter_a 0
#list addnmount /some/path # read-only mount path to expose it to dnsmasq
#Use dnsmasq as the local system resolver for local processes by default, however processes can still opt to use an alternative resolver
# localuse '0'
#When set to 0, use each network interface's dns address in the local /etc/resolv.conf. Normally, only the loopback address is used, and
# cachelocal '0'
# option resolvfile '/etc/resolv.dnsmasq-empty'
#Listening port for DNS queries, disables DNS server functionality if set to 0
# port '0'
config dhcp lan
option interface lan
option start 100
option limit 150
option leasetime 12h
config dhcp wan
option interface wan
option ignore 1
You tell dnsmasq not to run on the default port/disable it, how can failing local name look ups become a "big problem", when you killed them, on purpose ?
If you use localuse '0' the /tmp/resolv.conf will be linked to /tmp/resolv.conf.d/resolv.conf.auto
which contains your upstream DNS servers
You need a reboot for the new linking to take place
If you use localuse '1' then /tmp/resolv.conf will be linked to /etc/resolv.conf which points to 127.0.0.1 thus using DNSMasq as its resolver
Again you need a reboot for the new linking to take place
I've found reason for not resolving names in local applicantions. I've forgoten that also made some incorrect changes in /etc/dnsmasq.conf which caused not starting dnsmasq. Becase configured it from wan side without clients I've noticed it too late.
If you use localuse '0' the /tmp/resolv.conf will be linked to /tmp/resolv.conf.d/resolv.conf.auto
which contains your upstream DNS servers
I still get the same link to /tmp/resolv.conf. Even if I delete /etc/resolv.conf it is not created again after restarting with /etc/init.d/dnsmasq stop; /etc/init.d/dnsmasq start.
I probably did not explain it very well lets try again. /tmp/resolv.conf is auto generated by DNSMasq and if localuse =1 (default) it will generate a file which looks like this:
The file /etc/resolv.conf is what is used by the router for DNS resolution.
This is always linked to /tmp/resolv.conf:
root@X86:~# ls -la /etc/resolv.conf
lrwxrwxrwx 1 root root 16 Jun 29 09:53 /etc/resolv.conf -> /tmp/resolv.conf
The file /etc/resolv.conf is not auto generated and removing it will not bring it back automatically.
What happens if you use localuse = 0 is that the auto generated /tmp/resolv.conf is linked to /tmp/resolv.conf.d/resolv.conf.auto and thus shows all upstream DNS servers. /etc/resolv.conf is still linked to /tmp/resolv.conf so shows the contents of that file which on its turn is linked and thus shows the content of /tmp/resolv.conf.d/resolv.conf.auto
Magic word was reboot. Then anything began to work as expected. After your advice I made grep for word resolv in /etc/init.d and to my surprise I found it also in file boot.
Is there any special reason not to give this code from boot file to start of dnsmasq so we don't need reboot device after reconfiguration and only restart service? If yes it would be nice to mention this by describing localuse usage in documentation. Thanks for patience.
I had the reboot part in my notes, not sure why it is needed could be a bug of some sort.
So before adding this to the wiki that is something to be researched.
But great to hear it is working.
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.
Thanks!
I doubt a reboot should be necessary but maybe the file is in use or the order is wrong, so I think this is something that should be solvable.
The first thing to look at is indeed the dnsmasq.init script.
I have put it on my list
But at this moment I am looking into OpenVPN (Master branch)