local_nameservers now defaults to 127.* 0.0.0.0 255.255.255.255 ::1
authorRoy Marples <roy@marples.name>
Sun, 19 Oct 2014 20:19:00 +0000 (20:19 +0000)
committerRoy Marples <roy@marples.name>
Sun, 19 Oct 2014 20:19:00 +0000 (20:19 +0000)
and is used instead of a hard coded list.

libc.in
resolvconf.conf.5.in
resolvconf.in

diff --git a/libc.in b/libc.in
index 2e29e4fdb0bcc5c90035c173d9fb9d20ca393bc7..a657f8658b628edcc7fd787aa74a5eb99c27fa7e 100644 (file)
--- a/libc.in
+++ b/libc.in
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (c) 2007-2012 Roy Marples
+# Copyright (c) 2007-2014 Roy Marples
 # All rights reserved
 
 # libc subscriber for resolvconf
@@ -98,6 +98,7 @@ fi
 : ${libc_service:=nscd}
 : ${libc_restart:=@RESTARTCMD ${libc_service}@}
 : ${list_resolv:=@SBINDIR@/resolvconf -l}
+: ${local_nameservers:=127.* 0.0.0.0 255.255.255.255 ::1}
 if [ "${resolv_conf_head-x}" = x -a -f "$SYSCONFDIR"/resolv.conf.head ]; then
        resolv_conf_head="$(cat "${SYSCONFDIR}"/resolv.conf.head)"
 fi
@@ -137,14 +138,18 @@ case "${resolv_conf_passthrough:-NO}" in
        gotlocal=false
        for n in $(uniqify $prepend_nameservers $NS); do
                add=true
-               case "$n" in
-               127.*|0.0.0.0|255.255.255.255|::1) gotlocal=true;;
-               *)
+               islocal=false
+               for l in $local_nameservers; do
+                       case "$n" in
+                       $l) islocal=true; gotlocal=true; break;;
+                       esac
+               done
+               if ! $islocal; then
                        case "${resolv_conf_local_only:-YES}" in
                        [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
                                $gotlocal && add=false;;
                        esac
-               esac
+               fi
                $add && newns="$newns $n"
        done
 
index 22f811ffb59c85f19352aa5162bee3358ea83ad8..d0e37145753f2b05a8b58ed92717aa8dc109864b 100644 (file)
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd October 16, 2014
+.Dd October 19, 2014
 .Dt RESOLVCONF.CONF 5 SMM
 .Os
 .Sh NAME
@@ -58,6 +58,9 @@ If unset, defaults to the following:-
 These interfaces will be processed next, unless they have a metric.
 If unset, defaults to the following:-
 .D1 tap[0-9]* tun[0-9]* vpn vpn[0-9]* ppp[0-9]* ippp[0-9]*
+.It Sy local_nameservers
+If unset, defaults to the following:-
+.D1 127.* 0.0.0.0 255.255.255.255 ::1
 .It Sy search_domains
 Prepend search domains to the dynamically generated list.
 .It Sy search_domains_append
index 13dd95541b863fccab4a1806d131d801a1f93641..24895ade31e1d16f81f268aa4315b9f8a28a250e 100644 (file)
@@ -52,6 +52,7 @@ LOCKDIR="$VARDIR/lock"
 : ${dynamic_order:=tap[0-9]* tun[0-9]* vpn vpn[0-9]* ppp[0-9]* ippp[0-9]*}
 : ${interface_order:=lo lo[0-9]*}
 : ${name_server_blacklist:=0.0.0.0}
+: ${local_nameservers:=127.* 0.0.0.0 255.255.255.255 ::1}
 
 warn()
 {
@@ -120,7 +121,7 @@ echo_resolv()
 parse_resolv()
 {
        local line= ns= ds= search= d= n= newns=
-       local new=true iface= private=false p= domain=
+       local new=true iface= private=false p= domain= l= islocal=
 
        newns=
 
@@ -145,13 +146,17 @@ parse_resolv()
                        fi
                        ;;
                "nameserver "*)
-                       case "${line#* }" in
-                       127.*|0.0.0.0|255.255.255.255|::1)
-                               echo "LOCALNAMESERVERS=\"\$LOCALNAMESERVERS ${line#* }\""
-                               continue
-                               ;;
-                       esac
-                       ns="$ns${line#* } "
+                       islocal=false
+                       for l in $local_nameservers; do
+                               case "${line#* }" in
+                               $l)
+                                       islocal=true
+                                       echo "LOCALNAMESERVERS=\"\$LOCALNAMESERVERS ${line#* }\""
+                                       break
+                                       ;;
+                               esac
+                       done
+                       $islocal || ns="$ns${line#* } "
                        ;;
                "domain "*)
                        if [ -z "$domain" ]; then