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

Advertising

Mine
Wednesday, January 30th, 2008 at 12:23:14am 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 INPUT -i tun+ -j ACCEPT
  52. iptables -A INPUT -i TAP+ -j ACCEPT
  53. iptables -A FORWARD -i TAP+ -j FORWARD
  54. iptables -A FORWARD -i tun+ -j FORWARD
  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. iptables -A TRUSTED -i eth0 -p tcp -m tcp --dport 8080 -j ACCEPT
  63. iptables -A TRUSTED -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT
  64. iptables -A TRUSTED -i eth0 -p tcp -m tcp --dport 8081 -j ACCEPT
  65.  
  66.  
  67. #ftp
  68. iptables -A TRUSTED -i eth0 -p udp -m udp --dport 21 -j ACCEPT
  69. iptables -A TRUSTED -i eth0 -p tcp -m tcp --dport 21 -j ACCEPT
  70.  
  71. #vpn
  72. iptables -A TRUSTED -i eth0 -p tcp -m tcp --dport 1194 -j ACCEPT
  73.  
  74. # Allow IRC IDENT & DCC
  75. iptables -A TRUSTED -i eth0 -p tcp -m tcp --dport 6667 -j ACCEPT
  76. iptables -A TRUSTED -i eth0 -p tcp -m tcp --dport 113 -j ACCEPT
  77.  
  78. # Allow bittorrent
  79. iptables -A TRUSTED -i eth0 -p tcp -m tcp --dport 6881:6889 -j ACCEPT
  80.  
  81. #allow samba
  82. iptables -A INPUT -p udp -m udp --dport 137 -j ACCEPT
  83. iptables -A INPUT -p udp -m udp --dport 138 -j ACCEPT
  84. iptables -A INPUT -p tcp -m tcp --dport 139 -j ACCEPT
  85.  
  86. # End message
  87. 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
worth-right