Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. #!/bin/bash
  2. #clear iptables
  3. iptables -F
  4. iptables -X
  5.  
  6. #accept everything no matter port on localhost
  7. iptables -A INPUT -i lo -j ACCEPT
  8.  
  9. #allow established connections
  10. iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  11. iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  12.  
  13. #allow traffic going to specific outbound ports
  14. iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
  15. iptables -A INPUT -p tcp --sport 80 -j ACCEPT
  16.  
  17. iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
  18. iptables -A INPUT -p tcp --sport 443 -j ACCEPT
  19.  
  20. iptables -A OUTPUT -p tcp --dport 5938 -j ACCEPT
  21. iptables -A INPUT -p tcp --sport 5938 -j ACCEPT
  22.  
  23. iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT
  24. iptables -A INPUT -p tcp --sport 53 -j ACCEPT
  25.  
  26. iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
  27. iptables -A INPUT -p udp --sport 53 -j ACCEPT
  28.  
  29. #drop anything that doesn't match the rules above
  30. iptables -A INPUT -j DROP
  31. iptables -A OUTPUT -j DROP
  32. iptables -A FORWARD -j DROP
  33.  
  34. #!/bin/bash
  35.  
  36. #--------------------------------------
  37. #Clear iptables
  38. iptables -F -t nat
  39. iptables -X -t nat
  40. iptables -F -t filter
  41. iptables -X -t filter
  42.  
  43. #allow forward
  44. echo '1' > /proc/sys/net/ipv4/ip_forward
  45.  
  46. #default policy
  47. iptables -P INPUT DROP
  48. iptables -P FORWARD DROP
  49. iptables -P OUTPUT DROP
  50.  
  51.  
  52. #accept related and established connection
  53. iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  54. iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  55.  
  56. # DNS
  57. iptables -A INPUT -p tcp -m tcp --sport 53 -j ACCEPT
  58. iptables -A INPUT -p udp -m udp --sport 53 -j ACCEPT
  59. iptables -A OUTPUT -p tcp -m tcp --dport 53 -j ACCEPT
  60. iptables -A OUTPUT -p udp -m udp --dport 53 -j ACCEPT
  61.  
  62. # interfejs LO
  63. iptables -A INPUT -i lo -s 127.0.0.1 -j ACCEPT
  64. iptables -A OUTPUT -o lo -d 127.0.0.1 -j ACCEPT
  65.  
  66. #WWW
  67. iptables -A INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT
  68. iptables -A OUTPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT
  69.  
  70. #TEAMVIEWER
  71. iptables -A OUTPUT -o eth0 -p tcp --dport 5938 -m state --state NEW -j ACCEPT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement