Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. *filter
  2.  
  3. # Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
  4. -A INPUT -i lo -j ACCEPT
  5. -A INPUT -d 127.0.0.0/8 -j REJECT
  6.  
  7. # Accept all established inbound connections
  8. -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  9.  
  10. # Block anything from China
  11. # These rules are pulled from ipset's china list
  12. # The source file is at /etc/cn.zone (which in turn is generated by a shell script at /etc/block-china.sh )
  13. -A INPUT -p tcp -m set --match-set china src -j DROP
  14.  
  15. # Block bittorent
  16. -A INPUT -p tcp --dport 80 -m string --algo bm --string "Bittorrent" --to 1000 -j DROP
  17. -A INPUT -p tcp --dport 80 -m string --algo bm --string "GET /announce" --to 1000 -j DROP
  18.  
  19. # Limit connection speed to avoid DDOS
  20. -A INPUT -p tcp --dport 80 -m state --state NEW -m limit --limit 50/minute --limit-burst 200 -j ACCEPT
  21.  
  22. # Allow all outbound traffic - you can modify this to only allow certain traffic
  23. -A OUTPUT -j ACCEPT
  24.  
  25. # Allow HTTP and HTTPS connections from anywhere (the normal ports for websites and SSL).
  26. -A INPUT -p tcp --dport 80 -j ACCEPT
  27. -A INPUT -p tcp --dport 443 -j ACCEPT
  28.  
  29. # Allow SSH connections
  30. #
  31. # The -dport number should be the same port number you set in sshd_config
  32. #
  33. -A INPUT -p tcp -m state --state NEW --dport 2222 -j ACCEPT
  34.  
  35. # Allow ping
  36. -A INPUT -p icmp -j ACCEPT
  37.  
  38. # Log iptables denied calls
  39. -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
  40.  
  41. # Drop all other inbound - default deny unless explicitly allowed policy
  42. -A INPUT -j DROP
  43. -A FORWARD -j DROP
  44.  
  45. COMMIT
  46.  
  47. 110.255.172.42 - - [26/Apr/2015:18:05:41 +1200] "GET /announce.php?info_hash=M%3A%89%E1%86%9D%60%A7I%23%D6%99r%04%D7t%06%5F%A6%CC&peer_id=%2DSD0100%2D%E9%B1%EF%11A%CC%FB%94%EDl%23%8A&ip=101.28.113.60&port=8644&uploaded=1503508047&downloaded=1503508047&left=0&numwant=200&key=9253&compact=1 HTTP/1.0" 410 225 "-" "Bittorrent"
  48.  
  49. Chain INPUT (policy ACCEPT)
  50. target prot opt source destination
  51. ACCEPT all -- anywhere anywhere
  52. REJECT all -- anywhere 127.0.0.0/8 reject-with icmp-port-unreachable
  53. ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
  54. DROP tcp -- anywhere anywhere match-set china src
  55. DROP tcp -- anywhere anywhere tcp dpt:http STRING match "Bittorrent" ALGO name bm TO 1000
  56. DROP tcp -- anywhere anywhere tcp dpt:http STRING match "GET /announce" ALGO name bm TO 1000
  57. ACCEPT tcp -- anywhere anywhere tcp dpt:http state NEW limit: avg 50/min burst 200
  58. ACCEPT tcp -- anywhere anywhere tcp dpt:http
  59. ACCEPT tcp -- anywhere anywhere tcp dpt:https
  60. ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:2222
  61. ACCEPT icmp -- anywhere anywhere
  62. LOG all -- anywhere anywhere limit: avg 5/min burst 5 LOG level debug prefix "iptables denied: "
  63. DROP all -- anywhere anywhere
  64.  
  65. Chain FORWARD (policy ACCEPT)
  66. target prot opt source destination
  67. DROP all -- anywhere anywhere
  68.  
  69. Chain OUTPUT (policy ACCEPT)
  70. target prot opt source destination
  71. ACCEPT all -- anywhere anywhere
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement