Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. #!/bin/bash
  2. if [[ $EUID -ne 0 ]]; then
  3. echo "This script must be run as root" 1>&2
  4. exit 1
  5. fi
  6.  
  7. # name of primary network interface (before tunnel)
  8. PRIMARY=wlan0
  9.  
  10. # address of tunnel server
  11. SERVER=seattle.vpn.riseup.net
  12. # address of vpn server
  13. VPN_SERVER=seattle.vpn.riseup.net
  14.  
  15. # gateway ip address (before tunnel - adsl router ip address)
  16. # automatically determine the ip from the default route
  17. GATEWAY=`route -n | grep $PRIMARY | egrep "^0\.0\.0\.0" | tr -s " " | cut -d" " -f2`
  18.  
  19. # provided by pppd: interface name
  20. TUNNEL=tun0
  21.  
  22. openvpn --config /my/path/to/riseup.ovpn --auth-user-pass /my/path/to/authentication.conf &
  23.  
  24. # iptables rules - important!
  25.  
  26. #LOCAL_NET=192.168.0.0/16
  27. LOCAL_NET=$GATEWAY
  28.  
  29. # Flush all previous filter rules, you might not want to include this line if you already have other rules setup
  30. iptables -t filter --flush
  31.  
  32. iptables -t filter -X MYVPN
  33. iptables -t filter -N MYVPN
  34.  
  35. # Exceptions for local traffic & vpn server
  36. iptables -t filter -A MYVPN -o lo -j RETURN
  37. iptables -t filter -A MYVPN -o ${TUNNEL} -j RETURN
  38. iptables -t filter -A MYVPN --dst 127.0.0.1 -j RETURN
  39. iptables -t filter -A MYVPN --dst $LOCAL_NET -j RETURN
  40. iptables -t filter -A MYVPN --dst ${SERVER} -j RETURN
  41. iptables -t filter -A MYVPN --dst ${VPN_SERVER} -j RETURN
  42. # Add extra local nets here as necessary
  43.  
  44. iptables -t filter -A MYVPN -j DROP
  45.  
  46. # MYVPN traffic leaving this host:
  47. iptables -t filter -A OUTPUT -p tcp --syn -j MYVPN
  48. iptables -t filter -A OUTPUT -p icmp -j MYVPN
  49. iptables -t filter -A OUTPUT -p udp -j MYVPN
  50.  
  51. echo "nameserver 8.8.8.8" > /etc/resolv.conf
  52.  
  53. #!/bin/bash
  54. if [[ $EUID -ne 0 ]]; then
  55. echo "This script must be run as root" 1>&2
  56. exit 1
  57. fi
  58.  
  59. iptables -t filter --flush
  60. iptables -t filter -X MYVPN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement