Show Menu
Cheatography

IP tables Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

iptables

iptables -S [chain [number]]
print the rules in a chain or all chains
iptables -L -v
[-L] List rules as table in [-v] verboe mode
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
[-A] append rule. all INPUT traffic on [-p] protocol tcp, with [-dport] destin­ation port 22 (ssh) [-j] jump to ACCEPT
iptables -D INPUT 4
Delete the INPUT 4th rule
iptables -D INPUT -p tcp --dport 22 -j ACCEPT
[-D] Delete the specified rule
iptables -A INPUT -j DROP
all input traffic is DROP (DROP goes to a black hole and doesn't notify the user)
iptables -I INPUT 4 -p tcp --dport 443 -j ACCEPT
[-I] Insert rule on position 4
 

persis­tence

iptabl­es-save > ~/rules.v4
Save iptables rules to a file
iptabl­es-­restore < ~/rules.v4
Restore iptables rules from a file
apt-get install -y iptabl­es-­per­sistent
You can use iptabl­es-­per­sistent to save/r­estore rules at startup
sudo service netfil­ter­-pe­rsi­stent start
start previus installed service
sudo invoke­-rc.d netfil­ter­-pe­rsi­stent save
start netfilter at startup