Skip to content

Instantly share code, notes, and snippets.

@andrewvc
Created May 13, 2010 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrewvc/400491 to your computer and use it in GitHub Desktop.
Save andrewvc/400491 to your computer and use it in GitHub Desktop.
Simple iptables rules presets
*filter
# Internal interfaces
-A INPUT -i lo -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
#Allow all established traffic
-A INPUT -m state --state ESTABLISHED -j ACCEPT
#SSH
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --set
-I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --update --seconds 60 --hitcount 5 -j DROP
#HTTP
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
#HTTPS
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
# smtp server
#-A INPUT -p tcp -m tcp --dport smtp -m state --state NEW,ESTABLISHED -j ACCEPT
#-A INPUT -p tcp -m tcp --sport auth -m state --state ESTABLISHED -j ACCEPT
#SNMP Monitoring, enable only for monitor server ip
-A INPUT -s 127.0.0.1 -p udp -m udp --dport 161 -j ACCEPT
#ICMP
-A INPUT -p icmp -j ACCEPT
#Drop everything not mentioned
-A INPUT -j DROP
COMMIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment