Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate

Advertising

Someone
Monday, January 21st, 2008 at 12:09:37am UTC 

  1. #!/bin/bash
  2.  
  3. # No spoofing
  4. if [ -e /proc/sys/net/ipv4/conf/all/rp_filter ]
  5. then
  6. for filtre in /proc/sys/net/ipv4/conf/*/rp_filter
  7. do
  8. echo 1 > $filtre
  9. done
  10. fi
  11.  
  12. # No icmp
  13. echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
  14. echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
  15. echo 1 > /proc/sys/net/ipv4/ip_forward
  16. #load some modules you may need
  17. modprobe ip_tables
  18. modprobe ip_nat_ftp
  19. modprobe ip_nat_irc
  20. modprobe iptable_filter
  21. modprobe iptable_nat
  22. modprobe ip_conntrack_irc
  23. modprobe ip_conntrack_ftp
  24.  
  25. # Remove all rules and chains
  26. iptables -F
  27. iptables -X
  28.  
  29. # first set the default behaviour => accept connections
  30. iptables -P INPUT ACCEPT
  31. iptables -P OUTPUT ACCEPT
  32. iptables -P FORWARD ACCEPT
  33.  
  34. # Create 2 chains, it allows to write a clean script
  35. iptables -N FIREWALL
  36. iptables -N TRUSTED
  37.  
  38. # Allow ESTABLISHED and RELATED incoming connection
  39. iptables -A FIREWALL -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
  40. # Allow loopback traffic
  41. iptables -A FIREWALL -i lo -j ACCEPT
  42. # Send all package to the TRUSTED chain
  43. iptables -A FIREWALL -j TRUSTED
  44. # DROP all other packets
  45. iptables -A FIREWALL -j DROP
  46.  
  47. # Send all INPUT packets to the FIREWALL chain
  48. iptables -A INPUT -j FIREWALL
  49.  
  50. #openvpn
  51. iptables -A FORWARD -i tun+ -j ACCEPT
  52. iptables -A FORWARD -i TAP+ -j ACCEPT
  53. iptables -A FORWARD -i TAP+ -j FOWARD
  54. iptables -A FORWARD -i tun+ -j FOWARD
  55. iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
  56. iptables -A INPUT -i tun+ -j ACCEPT
  57.  
  58.  
  59. # Allow https
  60. iptables -A TRUSTED -i eth0 -p udp -m udp --dport 443 -j ACCEPT
  61. iptables -A TRUSTED -i eth0 -p tcp -m tcp --dport 443 -j ACCEPT
  62.  
  63. iptables -A INPUT -p tcp -m tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
  64.  
  65.  
  66. iptables -A INPUT -i eth0 -p tcp -m tcp --sport 21 -m state --state ESTABLISHED -j ACCEPT
  67. iptables -A INPUT -i eth0 -p tcp -m tcp --sport 20 -m state --state ESTABLISHED,RELATED -j ACCEPT
  68. iptables -A INPUT -i eth0 -p tcp -m tcp --sport 1024:65535 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
  69. iptables -A OUTPUT -o eth0 -p tcp -m tcp --dport 21 -m state --state NEW,ESTABLISHED -j ACCEPT
  70. iptables -A OUTPUT -o eth0 -p tcp -m tcp --dport 20 -m state --state ESTABLISHED -j ACCEPT
  71. iptables -A OUTPUT -o eth0 -p tcp -m tcp --sport 1024:65535 --dport 1024:65535 -m state --state ESTABLISHED,RELATED -j ACCEPT
  72.  
  73. # Allow IRC IDENT & DCC
  74. iptables -A TRUSTED -i eth0 -p tcp -m tcp --dport 6667 -j ACCEPT
  75. iptables -A TRUSTED -i eth0 -p tcp -m tcp --dport 113 -j ACCEPT
  76.  
  77. # Allow bittorrent
  78. iptables -A TRUSTED -i eth0 -p tcp -m tcp --dport 6881:6889 -j ACCEPT
  79.  
  80. # End message
  81. echo " [End iptables rules setting]"

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will not expire by default. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right