Skip to content

Instantly share code, notes, and snippets.

@changtimwu
Last active December 16, 2015 18:39
Show Gist options
  • Select an option

  • Save changtimwu/5479194 to your computer and use it in GitHub Desktop.

Select an option

Save changtimwu/5479194 to your computer and use it in GitHub Desktop.
DROP everything except web & ssh.
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 443 -j ACCEPT
iptables -A INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
iptables -A OUTPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
#uncomment the following if you want ping
#iptables -A INPUT -p ICMP --icmp-type 8 -j ACCEPT
#iptables -A OUTPUT -p ICMP --icmp-type 8 -j ACCEPT
#iptables -A INPUT -p ICMP --icmp-type 0 -j ACCEPT
#iptables -A OUTPUT -p ICMP --icmp-type 0 -j ACCEPT
iptables -A INPUT -j DROP
iptables -A OUTPUT -j DROP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment