Advertisement
Guest User

Untitled

a guest
Aug 11th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. ##############################################
  2. # INPUT RULES
  3. ##############################################
  4.  
  5. # loopback adapter
  6. iptables -A INPUT -i lo -j ACCEPT
  7.  
  8. # drop private petworks
  9. iptables -A INPUT -s 192.168.0.0/24 -j DROP # (C)
  10. iptables -A INPUT -s 172.16.0.0/12 -j DROP # (B)
  11. iptables -A INPUT -s 224.0.0.0/4 -j DROP # (MULTICAST D)
  12. iptables -A INPUT -s 240.0.0.0/5 -j DROP # (E)
  13. iptables -A INPUT -s 10.0.1.1 -j DROP # router
  14. iptables -A INPUT -d 10.0.1.255 -j DROP # broadcast
  15. iptables -A INPUT -d 255.255.255.255 -j DROP # broadcast
  16.  
  17. # related/established
  18. iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
  19.  
  20. # invalid
  21. iptables -A INPUT -m state --state INVALID -j DROP
  22.  
  23. # syn-flood protection
  24. iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 3 -j ACCEPT
  25.  
  26. # allow http
  27. iptables -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
  28.  
  29. # allow ssh only from LAN
  30. iptables -A INPUT -s 10.0.1.0/24 -m state --state NEW -p tcp --dport 65212 -j ACCEPT
  31.  
  32. # allow ping only from LAN
  33. iptables -A INPUT -s 10.0.1.0/24 -m state --state NEW -p icmp --icmp-type 8 -m limit --limit 1/s -j ACCEPT
  34.  
  35. # log the rest
  36. iptables -A INPUT -m limit --limit 2/min --limit-burst 2 -j LOG --log-prefix "INPUT DROP: "
  37.  
  38. # block everything else
  39. iptables -A INPUT -j DROP
  40.  
  41. ##############################################
  42. # OUTPUT RULES
  43. ##############################################
  44.  
  45. # loopback adapter
  46. iptables -A OUTPUT -o lo -j ACCEPT
  47.  
  48. # related/established
  49. iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
  50.  
  51. # allow dns queries
  52. iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
  53.  
  54. # allow http/https queries
  55. iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
  56. iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
  57.  
  58. # log the rest
  59. iptables -A OUTPUT -m limit --limit 2/min --limit-burst 2 -j LOG --log-prefix "OUTPUT DROP: "
  60.  
  61. # block everything else
  62. iptables -A OUTPUT -j DROP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement