Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
My generic iptables rule set
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i eth0 -p tcp ! --syn -m conntrack --ctstate NEW -j DROP
iptables -A INPUT -i eth0 -p tcp --tcp-flags ALL ALL -j DROP
iptables -A INPUT -i eth0 -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -i eth0 -p tcp --dport ssh -m conntrack --ctstate NEW -m recent --set --name SSH
iptables -A INPUT -i eth0 -p tcp --dport ssh -m conntrack --ctstate NEW -m recent --update --seconds 60 --hitcount 4 --rttl --name SSH -j DROP
iptables -A INPUT -i eth0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i eth0 -m conntrack --ctstate NEW -p tcp -m multiport --dports ssh,http,https -j ACCEPT
iptables -A INPUT -i eth0 -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
iptables -A INPUT -i eth0 -p icmp --icmp-type echo-reply -m limit --limit 1/s -j ACCEPT
iptables -A INPUT -i eth0 -p udp -m limit --limit 10/s -j ACCEPT
iptables -A INPUT -i eth0 -j DROP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment