Skip to content

Instantly share code, notes, and snippets.

@QueuingKoala
Created March 29, 2014 05:59
Show Gist options
  • Save QueuingKoala/9849354 to your computer and use it in GitHub Desktop.
Save QueuingKoala/9849354 to your computer and use it in GitHub Desktop.
#!/bin/sh
# This code available under a BSD 3-clause license
# http://opensource.org/licenses/BSD-3-Clause
# argument processing. Pass one of these to effect changes:
while [ -n "$1" ]
do
case "$1" in
-p|--allow-ping) do_ping=1 ;;
esac
shift
done
{
cat <<-==EOM
*filter
:INPUT DROP
:FORWARD DROP
:OUTPUT ACCEPT
-A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
-A INPUT -i lo -j ACCEPT
${do_ping:+-A INPUT -p icmp --icmp-type ping -j ACCEPT}
COMMIT
==EOM
} | iptables-restore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment