Guest User

firewall-kai.sh version 0.6.0

a guest
Sep 14th, 2021
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.91 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # The Unlicense
  4. # firewall-kai.sh version 0.6.0
  5.  
  6. 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'
  7.  
  8. iptables -t nat -F
  9.  
  10. iptables -t nat -A OUTPUT -p udp --dport 53 -j REDIRECT --to-port 9053
  11. iptables -t nat -A OUTPUT -p tcp -d 10.192.0.0/10 --syn -j REDIRECT --to-port 9040
  12.  
  13. iptables -t nat -A OUTPUT -m owner --uid-owner debian-tor -j RETURN
  14. iptables -t nat -A OUTPUT -o lo -j RETURN
  15.  
  16. iptables -t nat -A OUTPUT -p tcp --dport 443 -j RETURN
  17.  
  18. for sp in $SP; do
  19.     iptables -t nat -A OUTPUT -d $sp -j RETURN
  20. done
  21.  
  22. iptables -t nat -A OUTPUT -p tcp --syn -j REDIRECT --to-port 9040
  23.  
  24. iptables -t nat -nvL
  25.  
  26. iptables -F
  27.  
  28. iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT
  29. iptables -A INPUT -i lo -j ACCEPT
  30. iptables -A INPUT -j DROP
  31.  
  32. iptables -A FORWARD -j DROP
  33.  
  34. iptables -A OUTPUT -m state --state ESTABLISHED -j ACCEPT
  35.  
  36. iptables -A OUTPUT -p udp --dport 9053 -j ACCEPT
  37. iptables -A OUTPUT -p tcp --dport 9040 --syn -j ACCEPT
  38.  
  39. iptables -A OUTPUT -p tcp -m owner --uid-owner debian-tor --syn -j ACCEPT
  40. iptables -A OUTPUT -o lo -j ACCEPT
  41.  
  42. iptables -A OUTPUT -p tcp --dport 443 --syn -j ACCEPT
  43.  
  44. for sp in $SP; do
  45.     iptables -A OUTPUT -d $sp -j DROP
  46. done
  47.  
  48. iptables -A OUTPUT -j DROP
  49.  
  50. iptables -P INPUT DROP
  51. iptables -P FORWARD DROP
  52. iptables -P OUTPUT DROP
  53.  
  54. iptables -nvL
  55.  
  56. ip6tables -F
  57.  
  58. ip6tables -A INPUT -j DROP
  59.  
  60. ip6tables -A FORWARD -j DROP
  61.  
  62. ip6tables -A OUTPUT -j DROP
  63.  
  64. ip6tables -P INPUT DROP
  65. ip6tables -P FORWARD DROP
  66. ip6tables -P OUTPUT DROP
  67.  
  68. ip6tables -nvL
  69.  
  70. {
  71.     echo DNSPort 9053
  72.     echo AutomapHostsOnResolve 1
  73.     echo AutomapHostsSuffixes .onion
  74.     echo
  75.     echo TransPort 9040
  76.     echo VirtualAddrNetwork 10.192.0.0/10
  77. } > /etc/tor/torrc
  78.  
  79. systemctl restart tor
Add Comment
Please, Sign In to add comment