Advertisement
Guest User

Untitled

a guest
May 26th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3.  
  4. iptables -F
  5.  
  6. iptables -A INPUT -i lo -p all -j ACCEPT
  7.  
  8. iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  9.  
  10. iptables -A INPUT -s 10.0.0.0/8 -j DROP
  11. iptables -A INPUT -s 169.254.0.0/16 -j DROP
  12. iptables -A INPUT -s 172.16.0.0/12 -j DROP
  13. iptables -A INPUT -s 127.0.0.0/8 -j DROP
  14. iptables -A INPUT -s 192.168.0.0/24 -j DROP
  15.  
  16. iptables -A INPUT -s 224.0.0.0/4 -j DROP
  17. iptables -A INPUT -d 224.0.0.0/4 -j DROP
  18. iptables -A INPUT -s 240.0.0.0/5 -j DROP
  19. iptables -A INPUT -d 240.0.0.0/5 -j DROP
  20. iptables -A INPUT -s 0.0.0.0/8 -j DROP
  21. iptables -A INPUT -d 0.0.0.0/8 -j DROP
  22. iptables -A INPUT -d 239.255.255.0/24 -j DROP
  23. iptables -A INPUT -d 255.255.255.255 -j DROP
  24.  
  25.  
  26. iptables -A INPUT -p icmp -m icmp --icmp-type address-mask-request -j DROP
  27. iptables -A INPUT -p icmp -m icmp --icmp-type timestamp-request -j DROP
  28. iptables -A INPUT -p icmp -m icmp -m limit --limit 1/second -j ACCEPT
  29.  
  30.  
  31. iptables -A INPUT -m state --state INVALID -j DROP
  32. iptables -A FORWARD -m state --state INVALID -j DROP
  33. iptables -A OUTPUT -m state --state INVALID -j DROP
  34.  
  35.  
  36. iptables -A INPUT -p tcp -m tcp --tcp-flags RST RST -m limit --limit 2/second --limit-burst 2 -j ACCEPT
  37.  
  38.  
  39. iptables -A INPUT -m recent --name portscan --rcheck --seconds 86400 -j DROP
  40. iptables -A FORWARD -m recent --name portscan --rcheck --seconds 86400 -j DROP
  41.  
  42. iptables -A INPUT -m recent --name portscan --remove
  43. iptables -A FORWARD -m recent --name portscan --remove
  44.  
  45.  
  46. iptables -A INPUT -p tcp -m tcp --dport 139 -m recent --name portscan --set -j LOG --log-prefix "portscan:"
  47. iptables -A INPUT -p tcp -m tcp --dport 139 -m recent --name portscan --set -j DROP
  48.  
  49. iptables -A FORWARD -p tcp -m tcp --dport 139 -m recent --name portscan --set -j LOG --log-prefix "portscan:"
  50. iptables -A FORWARD -p tcp -m tcp --dport 139 -m recent --name portscan --set -j DROP
  51.  
  52.  
  53. iptables -A INPUT -p tcp -m tcp --dport 25 -j ACCEPT
  54. iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
  55. iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
  56. iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
  57. iptables -A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
  58. iptables -A INPUT -p tcp --match multiport --dports 2000:9999 -j ACCEPT
  59.  
  60.  
  61. iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
  62.  
  63. iptables -A INPUT -j REJECT
  64.  
  65.  
  66.  
  67. iptables -A OUTPUT -o lo -j ACCEPT
  68. iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  69.  
  70.  
  71.  
  72. iptables -A OUTPUT -p tcp -m tcp --dport 25 -j ACCEPT
  73. iptables -A OUTPUT -p udp -m udp --dport 53 -j ACCEPT
  74. iptables -A OUTPUT -p tcp -m tcp --dport 80 -j ACCEPT
  75. iptables -A OUTPUT -p tcp -m tcp --dport 443 -j ACCEPT
  76. iptables -A OUTPUT -p tcp -m tcp --dport 22 -j ACCEPT
  77. iptables -A OUTPUT -p tcp -m tcp --dport 21 -j ACCEPT
  78. iptables -A OUTPUT -p tcp --match multiport --dports 2000:9999 -j ACCEPT
  79.  
  80. # Allow pings
  81. iptables -A OUTPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
  82.  
  83. # Lastly Reject all Output traffic
  84. iptables -A OUTPUT -j REJECT
  85.  
  86. ## Reject Forwarding traffic
  87. iptables -A FORWARD -j REJECT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement