Skip to content

Instantly share code, notes, and snippets.

@RichardBarrell
Created April 18, 2013 21:23
Show Gist options
  • Save RichardBarrell/5416343 to your computer and use it in GitHub Desktop.
Save RichardBarrell/5416343 to your computer and use it in GitHub Desktop.
# Incoming, allow TCP 22, 80, 443 and all ICMP except redirect.
# Outgoing, allow everything.
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
iptables -F
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type redirect -j REJECT
iptables -A INPUT -p icmp -j ACCEPT
# REJECT is better than DROP. With DROP, people can tell the difference between
# a port that's blocked and a port that's open but doesn't have a listener yet.
iptables -A INPUT -j REJECT
/sbin/service iptables save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment