Browse Source

Tor hotspot

Bob Mottram 10 years ago
parent
commit
ff53f9010c
1 changed files with 31 additions and 36 deletions
  1. 31
    36
      install-freedombone.sh

+ 31
- 36
install-freedombone.sh View File

340
 # Broadcast address for wifi hotspot
340
 # Broadcast address for wifi hotspot
341
 WIFI_BROADCAST_ADDRESS="192.168.4.255"
341
 WIFI_BROADCAST_ADDRESS="192.168.4.255"
342
 
342
 
343
-# Comma separated list of DNS servers for wifi hotspot
344
-WIFI_DNS_SERVERS="213.73.91.35, 85.214.20.141"
343
+# space separated list of DNS servers for wifi hotspot
344
+WIFI_DNS_SERVERS="213.73.91.35 85.214.20.141"
345
 
345
 
346
 # message if something fails to install
346
 # message if something fails to install
347
 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."
347
 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."
590
   echo "    address $LOCAL_NETWORK_STATIC_IP_ADDRESS" >> /etc/network/interfaces
590
   echo "    address $LOCAL_NETWORK_STATIC_IP_ADDRESS" >> /etc/network/interfaces
591
   echo '    netmask 255.255.255.0' >> /etc/network/interfaces
591
   echo '    netmask 255.255.255.0' >> /etc/network/interfaces
592
   echo "    gateway $ROUTER_IP_ADDRESS" >> /etc/network/interfaces
592
   echo "    gateway $ROUTER_IP_ADDRESS" >> /etc/network/interfaces
593
-  echo '    dns-nameservers 213.73.91.35 85.214.20.141' >> /etc/network/interfaces
593
+  echo "    dns-nameservers $WIFI_DNS_SERVERS" >> /etc/network/interfaces
594
   echo '# Example to keep MAC address between reboots' >> /etc/network/interfaces
594
   echo '# Example to keep MAC address between reboots' >> /etc/network/interfaces
595
   echo '#hwaddress ether DE:AD:BE:EF:CA:FE' >> /etc/network/interfaces
595
   echo '#hwaddress ether DE:AD:BE:EF:CA:FE' >> /etc/network/interfaces
596
   echo '' >> /etc/network/interfaces
596
   echo '' >> /etc/network/interfaces
6982
 
6982
 
6983
   ### set variables
6983
   ### set variables
6984
   # Destinations you don't want routed through Tor
6984
   # Destinations you don't want routed through Tor
6985
-  _non_tor="192.168.1.0/24 192.168.0.0/24"
6985
+  _non_tor="192.168.4.0/24 192.168.1.0/24 192.168.0.0/24"
6986
 
6986
 
6987
   # The user that Tor runs as
6987
   # The user that Tor runs as
6988
   _tor_uid="debian-tor"
6988
   _tor_uid="debian-tor"
6993
   # Your internal interface
6993
   # Your internal interface
6994
   _int_if="eth0"
6994
   _int_if="eth0"
6995
 
6995
 
6996
+  # Ensure that redirects are possible
6997
+  sed -i "s/net.ipv4.conf.all.accept_redirects = 0/net.ipv4.conf.all.accept_redirects = 1/g" /etc/sysctl.conf
6998
+  sed -i "s/net.ipv4.conf.all.send_redirects = 0/net.ipv4.conf.all.send_redirects = 1/g" /etc/sysctl.conf
6999
+  sed -i "s/net.ipv4.conf.all.accept_source_route = 0/net.ipv4.conf.all.accept_source_route = 1/g" /etc/sysctl.conf
7000
+  sed -i "s/net.ipv4.conf.default.rp_filter=1/#net.ipv4.conf.default.rp_filter=1/g" /etc/sysctl.conf
7001
+  sed -i "s/net.ipv4.conf.all.rp_filter=1/#net.ipv4.conf.all.rp_filter=1/g" /etc/sysctl.conf
7002
+  #sed -i 's/net.ipv4.icmp_echo_ignore_all = 1/net.ipv4.icmp_echo_ignore_all = 0/g' /etc/sysctl.conf
7003
+
7004
+  #iptables --flush
7005
+  #iptables --table nat --flush
7006
+  #iptables --delete-chain
7007
+  #iptables --table nat --delete-chain
7008
+
6996
   ### Set iptables *nat
7009
   ### Set iptables *nat
6997
   iptables -t nat -A OUTPUT -o lo -j RETURN
7010
   iptables -t nat -A OUTPUT -o lo -j RETURN
6998
   iptables -t nat -A OUTPUT -m owner --uid-owner $_tor_uid -j RETURN
7011
   iptables -t nat -A OUTPUT -m owner --uid-owner $_tor_uid -j RETURN
7065
   fi
7078
   fi
7066
 
7079
 
7067
   echo 'route_outgoing_traffic_through_tor' >> $COMPLETION_FILE
7080
   echo 'route_outgoing_traffic_through_tor' >> $COMPLETION_FILE
7081
+
7082
+  if [[ $ENABLE_WIFI_HOTSPOT == "yes" ]]; then
7083
+      echo ''
7084
+      echo '  *** Freedombone Tor Wifi access point installation is complete. Rebooting... ***'
7085
+      echo ''
7086
+      cat /home/$MY_USERNAME/README
7087
+      reboot
7088
+  fi
7068
 }
7089
 }
7069
 
7090
 
7070
 # A command to create a git repository for a project
7091
 # A command to create a git repository for a project
7237
       echo "    dns-nameservers $ROUTER_IP_ADDRESS" >> /etc/network/interfaces
7258
       echo "    dns-nameservers $ROUTER_IP_ADDRESS" >> /etc/network/interfaces
7238
   fi
7259
   fi
7239
 
7260
 
7240
-  #sed -i 's/#net.ipv4.ip_forward/net.ipv4.ip_forward/g' /etc/sysctl.conf
7241
-  #sed -i 's/net.ipv4.ip_forward=.*/net.ipv4.ip_forward=1/g' /etc/sysctl.conf
7242
-  #echo 1 > /proc/sys/net/ipv4/ip_forward
7243
-
7244
-  #sed -i "s/net.ipv4.conf.all.accept_redirects = 0/net.ipv4.conf.all.accept_redirects = 1/g" /etc/sysctl.conf
7245
-  #sed -i "s/net.ipv4.conf.all.send_redirects = 0/net.ipv4.conf.all.send_redirects = 1/g" /etc/sysctl.conf
7246
-  #sed -i "s/net.ipv4.conf.all.accept_source_route = 0/net.ipv4.conf.all.accept_source_route = 1/g" /etc/sysctl.conf
7247
-  #sed -i "s/net.ipv4.conf.default.rp_filter=1/#net.ipv4.conf.default.rp_filter=1/g" /etc/sysctl.conf
7248
-  #sed -i "s/net.ipv4.conf.all.rp_filter=1/#net.ipv4.conf.all.rp_filter=1/g" /etc/sysctl.conf
7249
-  #sed -i "s/net.ipv4.ip_forward=0/#net.ipv4.ip_forward=1/g" /etc/sysctl.conf
7250
-  #sed -i 's/net.ipv4.icmp_echo_ignore_all = 1/net.ipv4.icmp_echo_ignore_all = 0/g' /etc/sysctl.conf
7251
-
7252
-  #iptables --flush
7253
-  #iptables --table nat --flush
7254
-  #iptables --delete-chain
7255
-  #iptables --table nat --delete-chain
7256
-  #iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
7257
-  #iptables -A FORWARD -i eth0 -o $WIFI_INTERFACE -m state --state RELATED,ESTABLISHED -j ACCEPT
7258
-  #iptables -A FORWARD -i $WIFI_INTERFACE -o eth0 -j ACCEPT
7259
-  #save_firewall_settings
7260
-
7261
   sed -i 's/option domain-name "example.org";/#option domain-name "example.org";/g' /etc/dhcp/dhcpd.conf
7261
   sed -i 's/option domain-name "example.org";/#option domain-name "example.org";/g' /etc/dhcp/dhcpd.conf
7262
   sed -i 's/option domain-name-servers ns1.example.org, ns2.example.org;/#option domain-name-servers ns1.example.org, ns2.example.org;/g' /etc/dhcp/dhcpd.conf
7262
   sed -i 's/option domain-name-servers ns1.example.org, ns2.example.org;/#option domain-name-servers ns1.example.org, ns2.example.org;/g' /etc/dhcp/dhcpd.conf
7263
   sed -i 's/#authoritative;/authoritative;/g' /etc/dhcp/dhcpd.conf
7263
   sed -i 's/#authoritative;/authoritative;/g' /etc/dhcp/dhcpd.conf
7276
 
7276
 
7277
   sed -i "s/INTERFACES=.*/INTERFACES='$WIFI_INTERFACE'/g" /etc/default/isc-dhcp-server
7277
   sed -i "s/INTERFACES=.*/INTERFACES='$WIFI_INTERFACE'/g" /etc/default/isc-dhcp-server
7278
 
7278
 
7279
-  service networking restart
7280
-  service hostapd restart
7281
-  systemctl daemon-reload
7282
-  service isc-dhcp-server restart
7283
-
7284
   # Add details to the README file
7279
   # Add details to the README file
7285
   if ! grep -q "Wifi Hotspot" /home/$MY_USERNAME/README; then
7280
   if ! grep -q "Wifi Hotspot" /home/$MY_USERNAME/README; then
7286
       echo '' >> /home/$MY_USERNAME/README
7281
       echo '' >> /home/$MY_USERNAME/README
7338
       sed -i "s/wifipassword/$WIFI_PASSWORD/g" /etc/network/interfaces
7333
       sed -i "s/wifipassword/$WIFI_PASSWORD/g" /etc/network/interfaces
7339
   fi
7334
   fi
7340
 
7335
 
7341
-  service networking restart
7342
-  if [ ! "$?" = "0" ]; then
7343
-      echo 'Unable to restart networking'
7344
-      exit 855
7345
-  fi
7346
-
7347
   # Add details to the README file
7336
   # Add details to the README file
7348
   if [[ ENABLE_WIFI != "yes" ]]; then
7337
   if [[ ENABLE_WIFI != "yes" ]]; then
7349
       if ! grep -q "Wifi Settings" /home/$MY_USERNAME/README; then
7338
       if ! grep -q "Wifi Settings" /home/$MY_USERNAME/README; then
7361
       fi
7350
       fi
7362
   fi
7351
   fi
7363
 
7352
 
7353
+  service networking restart
7354
+  if [ ! "$?" = "0" ]; then
7355
+      echo 'Unable to restart networking'
7356
+      exit 855
7357
+  fi
7358
+
7364
   echo 'enable_wifi' >> $COMPLETION_FILE
7359
   echo 'enable_wifi' >> $COMPLETION_FILE
7365
 }
7360
 }
7366
 
7361