Permalink
Browse files

prepend 127.0.0.1 to resolv.conf if not there

  • Loading branch information...
1 parent 9c8cf4e commit a348f869fb437bdb52f4c2b78df696e37514fc9f @markllama committed Jul 25, 2012
Showing with 6 additions and 4 deletions.
  1. +3 −4 bind-local.spec
  2. +3 −0 etc/dhcp/dhclient.d/bind-local.sh
View
@@ -73,10 +73,9 @@ EXT_IPADDRESS=$(ip addr show dev ${EXT_INTERFACE} | awk '/inet / {split($2,a,"/"
# separated by semi-colons suitable for inclusion in a BIND config list
FORWARDERS=$(awk '/^nameserver / {printf "%s ; ", $2}' /etc/resolv.conf)
-# insert the external address before the first nameserver line
-sed -i -e "1,/nameserver/ { /nameserver/ i\
-nameserver ${EXT_IPADDRESS}
-}" /etc/resolv.conf
+# insert the loopback address before the first nameserver line
+grep 127.0.0.1 /etc/resolv.conf >/dev/null || sed -i -e '1anameserver 127.0.0.1' /etc/resolv.conf
+
# Set up the initial forwarder
echo "forwarders { ${FORWARDERS} } ;" > /var/named/forwarders.conf
@@ -105,6 +105,9 @@ EOF
logmessage "no new IP address provided by DHCP"
fi
+ # insert the loopback address before the first nameserver line
+ grep 127.0.0.1 /etc/resolv.conf >/dev/null || sed -i -e '1anameserver 127.0.0.1' /etc/resolv.conf
+
}
function bind-local_restore() {

0 comments on commit a348f86

Please sign in to comment.