Snippets for yer computer needs




Set up default DROP rule for eth0

iptables -P INPUT DROP

Allow existing connections to continue

iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

Accept everything from the 192.168.1.x network

iptables -A INPUT -i eth0 -s -j ACCEPT

Drop a single host

iptables -I INPUT -s -j DROP

Allow connections from this host to

iptables -A OUTPUT -o eth0 -d -j ACCEPT

Flush table

iptables –flush

Allow incoming HTTP

iptables -A INPUT -i eth0 -p tcp –dport 80 -m state –state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -o eth0 -p tcp –sport 80 -m state –state ESTABLISHED -j ACCEPT

Limit connections

iptables -A INPUT -p tcp –dport 80 -m limit –limit 25/minute –limit-burst 100 -j ACCEPT

Simple IP masquerading

echo “1” > /proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -o $EXT_IFACE -j MASQUERADE

Backup, reload iptables rules

iptables-save > ./file iptables-restore < ./file

File location