Skip to content

Instantly share code, notes, and snippets.

@codingfoo
Last active December 17, 2015 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingfoo/5640180 to your computer and use it in GitHub Desktop.
Save codingfoo/5640180 to your computer and use it in GitHub Desktop.
Basic iptables config
https://help.ubuntu.com/community/IptablesHowTo
Place the scripts in
/etc/network/if-pre-up.d and /etc/network/if-post-down.d
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
[0:0] -A INPUT -i lo -j ACCEPT
[0:0] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
[0:0] -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
[0:0] -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
[0:0] -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
[0:0] -A INPUT -j DROP
COMMIT
#!/bin/sh
iptables-restore < /etc/iptables.rules
exit 0
#!/bin/sh
iptables-save -c > /etc/iptables.rules
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment