]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
Merge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into next
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 4 Oct 2016 21:34:23 +0000 (22:34 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 4 Oct 2016 21:34:23 +0000 (22:34 +0100)
config/rootfiles/core/106/exclude
src/initscripts/init.d/networking/red.up/05-update-dns-forwarders
src/initscripts/init.d/unbound

index 1d8d74e219b19ead292772df6767b59536f86758..7ddeae0ba387ee9ad5e6f4f83836b3319d314148 100644 (file)
@@ -23,7 +23,6 @@ var/ipfire/dma
 var/ipfire/time
 var/ipfire/ovpn
 var/lib/alternatives
-var/lib/unbound/root.key
 var/log/cache
 var/state/dhcp/dhcpd.leases
 var/updatecache
index be8879ca9e1ce3220a63086f984705d4ac52720e..4ff2e58ef746a628b35405cf5f448fba4f4693e5 100644 (file)
@@ -3,10 +3,11 @@
 # If network has not fully been brought up here, we start unbound
 # so that all following scripts can rely on DNS resolution
 
-# Update DNS forwarders if unbound is running
-if pgrep -q unbound; then
-       exec /etc/init.d/unbound update-forwarders
+pidof unbound > /dev/null
+if [ "${?}" = "0" ]; then
+       # unbound is run so update the forwarders
+       /etc/init.d/unbound update-forwarders
+else
+       # Start unbound if it is not running, yet
+       /etc/init.d/unbound start
 fi
-
-# Start unbound if it is not running, yet
-exec /etc/init.d/unbound start
index dd5c85c7b5f1bbeaeda827c67e3488c430d80b6b..d324457d163e7294c362eff7f052ea11a783b3a7 100644 (file)
@@ -44,6 +44,15 @@ function cidr() {
     echo "${cidr}/${nbits}"
 }
 
+ip_address_revptr() {
+       local addr=${1}
+
+       local a1 a2 a3 a4
+       IFS=. read -r a1 a2 a3 a4 <<< ${addr}
+
+       echo "${a4}.${a3}.${a2}.${a1}.in-addr.arpa"
+}
+
 read_name_servers() {
        local i
        for i in 1 2; do
@@ -101,6 +110,23 @@ update_forwarders() {
        unbound-control -q forward off
 }
 
+own_hostname() {
+       local hostname=$(hostname -f)
+       # 1.1.1.1 is reserved for green only, skip this
+       if [ -n "${GREEN_ADDRESS}" -a "${GREEN_ADDRESS}" != "1.1.1.1" ]; then
+               unbound-control -q local_data "${hostname} ${LOCAL_TTL} IN A ${GREEN_ADDRESS}"
+       fi
+
+       local address
+       for address in ${GREEN_ADDRESS} ${BLUE_ADDRESS} ${ORANGE_ADDRESS}; do
+               [ -n "${address}" ] || continue
+               [ "${address}" = "1.1.1.1" ] && continue
+
+               address=$(ip_address_revptr ${address})
+               unbound-control -q local_data "${address} ${LOCAL_TTL} IN PTR ${hostname}"
+       done
+}
+
 update_hosts() {
        local enabled address hostname domainname
 
@@ -111,6 +137,10 @@ update_hosts() {
                local fqdn="${hostname}.${domainname}"
 
                unbound-control -q local_data "${fqdn} ${LOCAL_TTL} IN A ${address}"
+
+               # Add RDNS
+               address=$(ip_address_revptr ${address})
+               unbound-control -q local_data "${address} ${LOCAL_TTL} IN PTR ${fqdn}"
        done < /var/ipfire/main/hosts
 }
 
@@ -307,6 +337,9 @@ case "$1" in
                boot_mesg "Starting Unbound DNS Proxy..."
                loadproc /usr/sbin/unbound || exit $?
 
+               # Make own hostname resolveable
+               own_hostname
+
                # Update any known forwarding name servers
                update_forwarders