Currently, dnsmasq removes /tmp/resolv.conf (which is usually a symlink to /tmp/resolv.conf.auto) and creates its own resolv.conf with at least a nameserver pointing to 127.0.0.1.
However, in some cases it might not be desired that the router itself queries its own dnsmasq dns-server but should query the upstream dns server - possibly fetched via an additional, local dhcp client - directly instead. With this new uci configuration option it is possible to prohibit dnsmasq to change /tmp/resolv.conf, leaving it as provided by the udhcpd. Signed-off-by: Linus Lüssing <linus.luess...@web.de> --- * shortened the option name * commented this option out in the default dhcp.conf to make clear that it's optional and should not break any old configs package/dnsmasq/files/dhcp.conf | 1 + package/dnsmasq/files/dnsmasq.init | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package/dnsmasq/files/dhcp.conf b/package/dnsmasq/files/dhcp.conf index 5ba772e..2d7f185 100644 --- a/package/dnsmasq/files/dhcp.conf +++ b/package/dnsmasq/files/dhcp.conf @@ -20,6 +20,7 @@ config dnsmasq #list interface br-lan #list notinterface lo #list bogusnxdomain '64.94.110.11' + #option keepresolvcf 0 config dhcp lan option interface lan diff --git a/package/dnsmasq/files/dnsmasq.init b/package/dnsmasq/files/dnsmasq.init index 9518df3..5570d35 100644 --- a/package/dnsmasq/files/dnsmasq.init +++ b/package/dnsmasq/files/dnsmasq.init @@ -114,6 +114,8 @@ dnsmasq() { config_get hostsfile "$cfg" dhcphostsfile [ -e "$hostsfile" ] && append args "--dhcp-hostsfile=$hostsfile" + config_get_bool keepresolvcf "$cfg" keepresolvcf + local rebind config_get_bool rebind "$cfg" rebind_protection 1 [ $rebind -gt 0 ] && { @@ -388,8 +390,9 @@ start() { config_foreach dhcp_srv_add srvhost config_foreach dhcp_add dhcp - /usr/sbin/dnsmasq $args && { + /usr/sbin/dnsmasq $args && [ ! "$keepresolvcf" = "1" ] && { rm -f /tmp/resolv.conf + echo "### Created by dnsmasq.init ###" >> /tmp/resolv.conf [ -n "$DOMAIN" ] && echo "search $DOMAIN" >> /tmp/resolv.conf DNS_SERVERS="$DNS_SERVERS 127.0.0.1" for DNS_SERVER in $DNS_SERVERS ; do @@ -399,7 +402,8 @@ start() { } stop() { - [ -f /tmp/resolv.conf ] && { + [ -f /tmp/resolv.conf ] && \ + [ "`head -n1 /tmp/resolv.conf`" = "### Created by dnsmasq.init ###" ] && { rm -f /tmp/resolv.conf ln -s /tmp/resolv.conf.auto /tmp/resolv.conf } -- 1.7.5.4 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel