Advertisement
Guest User

iptables

a guest
Jul 1st, 2015
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. echo "* Removing current iptable rules.."
  4. iptables -P INPUT ACCEPT
  5. iptables -P OUTPUT ACCEPT
  6. iptables -F
  7.  
  8. echo "* Adding new rules..."
  9. iptables -A INPUT -m tcp -p tcp --dport 22 -j ACCEPT -m comment --comment "Allow SSH"
  10. iptables -A INPUT -m tcp -p tcp --dport 80 -j ACCEPT -m comment --comment "Allow HTTP"
  11. iptables -A INPUT -m tcp -p tcp --dport 21 -j ACCEPT -m comment --comment "Allow FTP"
  12. iptables -A INPUT -p tcp --match multiport --dports 6666:6699 -j ACCEPT -m comment --comment "Allow ircd range"
  13. iptables -A INPUT -p udp -m udp --sport 53 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT -m comment --comment "Allow DNS udp"
  14. iptables -A INPUT -p tcp -m tcp --sport 53 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT -m comment --comment "Allow DNS tcp"
  15. iptables -A INPUT -p icmp --icmp-type 0 -s 0/0 -m state --state ESTABLISHED,RELATED -j ACCEPT -m comment --comment "Allow ICMP"
  16. iptables -A INPUT -p icmp --icmp-type 8 -s 0/0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT -m comment --comment "Allow ICMP ping"
  17.  
  18. iptables -L
  19.  
  20. echo
  21. echo "--------------------------"
  22. echo "If everything looks good then run this command;"
  23. echo -e "iptables -P INPUT DROP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement