Parcourir la source

Allow DNS nameservers to be configured

Bob Mottram il y a 10 ans
Parent
révision
9787e95171
2 fichiers modifiés avec 26 ajouts et 4 suppressions
  1. BIN
      man/freedombone.1.gz
  2. 26
    4
      src/freedombone

BIN
man/freedombone.1.gz Voir le fichier


+ 26
- 4
src/freedombone Voir le fichier

@@ -81,6 +81,10 @@ LOCAL_NETWORK_STATIC_IP_ADDRESS="192.168.1.60"
81 81
 # IP address of the router (gateway)
82 82
 ROUTER_IP_ADDRESS="192.168.1.254"
83 83
 
84
+# DNS
85
+NAMESERVER1='213.73.91.35'
86
+NAMESERVER2='85.214.20.141'
87
+
84 88
 # whether to route outgoing traffic through Tor
85 89
 ROUTE_THROUGH_TOR="no"
86 90
 
@@ -375,6 +379,8 @@ function show_help {
375 379
   echo '     --cjdns            Enable CJDNS'
376 380
   echo '     --vpass            VoIP server password'
377 381
   echo '     --vport            VoIP server port'
382
+  echo '     --ns1              First DNS nameserver'
383
+  echo '     --ns2              Second DNS nameserver'
378 384
   echo ''
379 385
   echo 'system types'
380 386
   echo '------------'
@@ -1047,6 +1053,16 @@ case $key in
1047 1053
     shift
1048 1054
     VOIP_PORT=$1
1049 1055
     ;;
1056
+    # DNS Nameserver 1
1057
+    --ns1)
1058
+    shift
1059
+    NAMESERVER1=$1
1060
+    ;;
1061
+    # DNS Nameserver 2
1062
+    --ns2)
1063
+    shift
1064
+    NAMESERVER2=$1
1065
+    ;;
1050 1066
     *)
1051 1067
     # unknown option
1052 1068
     ;;
@@ -1099,9 +1115,15 @@ function read_configuration {
1099 1115
   fi
1100 1116
 
1101 1117
   if [ -f $CONFIGURATION_FILE ]; then
1118
+      if grep -q "NAMESERVER1" $CONFIGURATION_FILE; then
1119
+          NAMESERVER1=$(grep "NAMESERVER1" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
1120
+      fi
1121
+      if grep -q "NAMESERVER2" $CONFIGURATION_FILE; then
1122
+          NAMESERVER2=$(grep "NAMESERVER2" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
1123
+      fi
1102 1124
       if grep -q "DEBIAN_REPO" $CONFIGURATION_FILE; then
1103 1125
           DEBIAN_REPO=$(grep "DEBIAN_REPO" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
1104
-		  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."
1126
+          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."
1105 1127
       fi
1106 1128
       if grep -q "VOIP_PORT" $CONFIGURATION_FILE; then
1107 1129
           VOIP_PORT=$(grep "VOIP_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
@@ -1386,7 +1408,7 @@ function install_not_on_BBB {
1386 1408
   echo "    address $LOCAL_NETWORK_STATIC_IP_ADDRESS" >> /etc/network/interfaces
1387 1409
   echo '    netmask 255.255.255.0' >> /etc/network/interfaces
1388 1410
   echo "    gateway $ROUTER_IP_ADDRESS" >> /etc/network/interfaces
1389
-  echo '    dns-nameservers 213.73.91.35 85.214.20.141' >> /etc/network/interfaces
1411
+  echo "    dns-nameservers $NAMESERVER1 $NAMESERVER2" >> /etc/network/interfaces
1390 1412
   echo '# Example to keep MAC address between reboots' >> /etc/network/interfaces
1391 1413
   echo '#hwaddress ether DE:AD:BE:EF:CA:FE' >> /etc/network/interfaces
1392 1414
   echo '' >> /etc/network/interfaces
@@ -4645,8 +4667,8 @@ function configure_dns {
4645 4667
   fi
4646 4668
   echo 'domain localdomain' > /etc/resolv.conf
4647 4669
   echo 'search localdomain' >> /etc/resolv.conf
4648
-  echo 'nameserver 213.73.91.35' >> /etc/resolv.conf
4649
-  echo 'nameserver 85.214.20.141' >> /etc/resolv.conf
4670
+  echo "nameserver $NAMESERVER1" >> /etc/resolv.conf
4671
+  echo "nameserver $NAMESERVER2" >> /etc/resolv.conf
4650 4672
   echo 'configure_dns' >> $COMPLETION_FILE
4651 4673
 }
4652 4674