Skip to content

Instantly share code, notes, and snippets.

@laetrid
Created June 28, 2016 16:32
Show Gist options
  • Save laetrid/868a61dc2d96e421813aa225d0c07492 to your computer and use it in GitHub Desktop.
Save laetrid/868a61dc2d96e421813aa225d0c07492 to your computer and use it in GitHub Desktop.
Basic iptables config for newly installed Linux
# list iptables rules
iptables -L -vn
# flush iptables in chain, or everywhere if run without chain name
iptables -F
# change dafault chane rule
iptables -P FORWARD DROP
# append a new rule
iptables -A INPUT -p tcp -s 185.51.156.255 -j ACCEPT
# insert a new rule (here in 12th position)
iptables -I INPUT 12 -s 10.18.129.11/32 -j ACCEPT
# add CONNECTED/RELATED
iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
# Save the rules #
# Debian
apt-get update
apt-get install iptables-persistent
service iptables-persistent {start|restart|reload|force-reload|save|flush}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment