From 9d4858c07e1eef8b93c354fa64c6c801d68282ee Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 22 Jun 2017 17:52:52 +0100 Subject: [PATCH] Use resolvconf for dns resolution --- src/freedombone-image-customise | 5 ++++- src/freedombone-utils-config | 2 +- src/freedombone-utils-dns | 6 ++++-- src/freedombone-utils-onion | 10 ++++------ src/freedombone-utils-setup | 2 +- src/freedombone-utils-wifi | 2 -- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/freedombone-image-customise b/src/freedombone-image-customise index 2483f2de..63c7c441 100755 --- a/src/freedombone-image-customise +++ b/src/freedombone-image-customise @@ -178,6 +178,8 @@ EOF } configure_networking() { + chroot "$rootdir" apt-get -yq install resolvconf + if [[ "$MACHINE" == "beaglebonewifi" ]]; then # Allow networking over USB in order to configure the # wifi login settings @@ -244,7 +246,7 @@ iface eth0 inet static fi # configure DNS - resolvconf=$rootdir/etc/resolv.conf + resolvconf=$rootdir/etc/resolvconf/resolv.conf.d/head echo 'domain localdomain' > $resolvconf echo 'search localdomain' >> $resolvconf echo "nameserver $NAMESERVER1" >> $resolvconf @@ -253,6 +255,7 @@ iface eth0 inet static echo "nameserver $NAMESERVER4" >> $resolvconf echo "nameserver $NAMESERVER5" >> $resolvconf echo "nameserver $NAMESERVER6" >> $resolvconf + chroot "$rootdir" resolvconf -u if [[ $VARIANT != "meshclient" && $VARIANT != "meshusb" ]]; then # change the motd to show further install instructions diff --git a/src/freedombone-utils-config b/src/freedombone-utils-config index 06247c9c..831cbb0a 100755 --- a/src/freedombone-utils-config +++ b/src/freedombone-utils-config @@ -316,7 +316,7 @@ function read_configuration_values { if grep -q "DEBIAN_REPO" $CONFIGURATION_FILE; then read_config_param "DEBIAN_REPO" - CHECK_MESSAGE=$"Check your internet connection, /etc/network/interfaces and /etc/resolv.conf, then delete $COMPLETION_FILE, run 'rm -fR /var/lib/apt/lists/* && apt-get update --fix-missing' and run this script again. If hash sum mismatches persist then try setting $DEBIAN_REPO to a different mirror and also change /etc/apt/sources.list." + CHECK_MESSAGE=$"Check your internet connection, /etc/network/interfaces and /etc/resolvconf/resolv.conf.d/head, then delete $COMPLETION_FILE, run 'rm -fR /var/lib/apt/lists/* && apt-get update --fix-missing' and run this script again. If hash sum mismatches persist then try setting $DEBIAN_REPO to a different mirror and also change /etc/apt/sources.list." fi fi } diff --git a/src/freedombone-utils-dns b/src/freedombone-utils-dns index 2dc6e444..31a30ab7 100755 --- a/src/freedombone-utils-dns +++ b/src/freedombone-utils-dns @@ -196,7 +196,9 @@ function configure_dns { return fi - resolvconf=/etc/resolv.conf + apt-get -yq install resolvconf + + resolvconf=/etc/resolvconf/resolv.conf.d/head # allow changes to resolv.conf chattr -i $resolvconf @@ -211,7 +213,7 @@ function configure_dns { echo "nameserver $NAMESERVER6" >> $resolvconf # prevent resolv.conf from changing - chattr +i $resolvconf + resolvconf -u mark_completed $FUNCNAME } diff --git a/src/freedombone-utils-onion b/src/freedombone-utils-onion index 7f91d64a..e1f5697b 100755 --- a/src/freedombone-utils-onion +++ b/src/freedombone-utils-onion @@ -310,10 +310,9 @@ function resolve_dns_via_tor { sed -i 's|, domain-name-servers||g' /etc/dhcp/dhclient.conf # point resolv.conf to tor - resolvconf=/etc/resolv.conf - chattr -i $resolvconf + resolvconf=/etc/resolvconf/resolv.conf.d/head echo 'nameserver 127.0.0.1:53' > $resolvconf - chattr +i $resolvconf + resolvconf -u mark_completed $FUNCNAME } @@ -378,12 +377,11 @@ function route_outgoing_traffic_through_tor { /sbin/sysctl -p -q fi - resolvconf=/etc/resolv.conf - chattr -i $resolvconf + resolvconf=/etc/resolvconf/resolv.conf.d/head echo 'domain localdomain' > $resolvconf echo 'search localdomain' >> $resolvconf echo 'nameserver 127.0.0.1' >> $resolvconf - chattr +i $resolvconf + resolvconf -u if ! grep -q "VirtualAddrNetworkIPv4" /etc/tor/torrc; then echo 'VirtualAddrNetworkIPv4 10.192.0.0/10' >> /etc/tor/torrc diff --git a/src/freedombone-utils-setup b/src/freedombone-utils-setup index 9ace64d8..3af30c15 100755 --- a/src/freedombone-utils-setup +++ b/src/freedombone-utils-setup @@ -80,7 +80,7 @@ COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt REMOTE_BACKUPS_LOG=/var/log/remotebackups.log # message if something fails to install -CHECK_MESSAGE="Check your internet connection, /etc/network/interfaces and /etc/resolv.conf, then delete $COMPLETION_FILE, run 'rm -fR /var/lib/apt/lists/* && apt-get update --fix-missing' and run this script again. If hash sum mismatches persist then try setting $DEBIAN_REPO to a different mirror and also change /etc/apt/sources.list." +CHECK_MESSAGE="Check your internet connection, /etc/network/interfaces and /etc/resolvconf/resolv.conf.d/head, then delete $COMPLETION_FILE, run 'rm -fR /var/lib/apt/lists/* && apt-get update --fix-missing' and run this script again. If hash sum mismatches persist then try setting $DEBIAN_REPO to a different mirror and also change /etc/apt/sources.list." # Default diffie-hellman key length in bits DH_KEYLENGTH=2048 diff --git a/src/freedombone-utils-wifi b/src/freedombone-utils-wifi index a3994af5..4f9e797d 100755 --- a/src/freedombone-utils-wifi +++ b/src/freedombone-utils-wifi @@ -466,8 +466,6 @@ function networks_from_file { fi done < $WIFI_NETWORKS_FILE - resolvconf=/etc/resolv.conf - chattr -i $resolvconf systemctl restart network-manager #ifconfig ${WIFI_INTERFACE} up ifup $WIFI_INTERFACE