Skip to content

Instantly share code, notes, and snippets.

@jcsalterego
Created May 2, 2012 16:09
Show Gist options
  • Select an option

  • Save jcsalterego/2577831 to your computer and use it in GitHub Desktop.

Select an option

Save jcsalterego/2577831 to your computer and use it in GitHub Desktop.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
#
# Blacklist
#
-A INPUT -s 1.1.1.1 -j DROP
#
# Base rules
#
-A INPUT -i lo -j ACCEPT
-A INPUT -d 127.0.0.0/255.0.0.0 -i ! lo -j REJECT --reject-with icmp-port-unreachable
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#
# Whitelist TCP Ports
#
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
#
# Allow hosts
#
-A INPUT -s 2.2.2.2 -m state --state NEW -j ACCEPT
#
# Other protect
#
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
-A INPUT -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -j REJECT --reject-with icmp-port-unreachable
-A OUTPUT -j ACCEPT
COMMIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment