Skip to content

Instantly share code, notes, and snippets.

@edencorbin
Last active February 9, 2016 21:40
Show Gist options
  • Save edencorbin/10bf8f53bdde45a0d758 to your computer and use it in GitHub Desktop.
Save edencorbin/10bf8f53bdde45a0d758 to your computer and use it in GitHub Desktop.
iptables_configuration
flush
iptables -F
drop all input (note this will end an ssh session, further commands need to be run as root from console)
iptables -P INPUT DROP
block null packets
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
syn-flood attack protection
iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
XMAS packets protection
iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
Allow local host
iptables -A INPUT -i lo -p all -j ACCEPT
Now we can allow web server traffic:
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
Allow related, established
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment