Guest User

firewall.sh version 0.10.0

a guest
Sep 17th, 2021
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.80 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # The Unlicense
  4.  
  5. SP='255.255.255.255/32 240.0.0.0/4 233.252.0.0/24 224.0.0.0/4 203.0.113.0/24 198.51.100.0/24 198.18.0.0/15 192.168.0.0/16 192.88.99.0/24 192.0.2.0/24 192.0.0.0/24 172.16.0.0/12 169.254.0.0/16 127.0.0.0/8 100.64.0.0/10 10.0.0.0/8 0.0.0.0/8'
  6.  
  7. # ---
  8.  
  9. iptables -t nat -F
  10.  
  11. iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination='127.0.0.1:9053'
  12. iptables -t nat -A OUTPUT -p tcp -d 10.192.0.0/10 --syn -j DNAT --to-destination='127.0.0.1:9040'
  13.  
  14. iptables -t nat -A OUTPUT -m owner --uid-owner debian-tor -j RETURN
  15. iptables -t nat -A OUTPUT -o lo -j RETURN
  16.  
  17. for sp in $SP; do
  18.   iptables -t nat -A OUTPUT -d $sp -j RETURN
  19. done
  20.  
  21. iptables -t nat -A OUTPUT -p tcp --syn -j DNAT --to-destination='127.0.0.1:9040'
  22.  
  23. iptables -t nat -nvL
  24.  
  25. # ---
  26.  
  27. iptables -F
  28.  
  29. iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT
  30. iptables -A INPUT -i lo -j ACCEPT
  31. iptables -A INPUT -j DROP
  32.  
  33. iptables -A FORWARD -j DROP
  34.  
  35. iptables -A OUTPUT -m state --state ESTABLISHED -j ACCEPT
  36.  
  37. iptables -A OUTPUT -p udp -d 127.0.0.1 --dport 9053 -j ACCEPT
  38. iptables -A OUTPUT -p tcp -d 127.0.0.1 --dport 9040 --syn -j ACCEPT
  39.  
  40. iptables -A OUTPUT -p tcp -m owner --uid-owner debian-tor --syn -j ACCEPT
  41. iptables -A OUTPUT -o lo -j ACCEPT
  42.  
  43. for sp in $SP; do
  44.   iptables -A OUTPUT -d $sp -j DROP
  45. done
  46.  
  47. iptables -A OUTPUT -j DROP
  48.  
  49. iptables -nvL
  50.  
  51. # ---
  52.  
  53. ip6tables -F
  54.  
  55. ip6tables -A INPUT -j DROP
  56.  
  57. ip6tables -A FORWARD -j DROP
  58.  
  59. ip6tables -A OUTPUT -j DROP
  60.  
  61. ip6tables -nvL
  62.  
  63. # ---
  64.  
  65. {
  66.   echo ExitNodes {jp}
  67.   echo EntryNodes {jp}
  68.   echo MiddleNodes {jp}
  69.   echo
  70.   echo DNSPort 127.0.0.1:9053
  71.   echo AutomapHostsOnResolve 1
  72.   echo AutomapHostsSuffixes .onion
  73.   echo
  74.   echo TransPort 127.0.0.1:9040
  75.   echo VirtualAddrNetwork 10.192.0.0/10
  76. } > /etc/tor/torrc
  77.  
  78. systemctl restart tor
Add Comment
Please, Sign In to add comment