Ubuntu/iptables
From r00tedvw.com wiki
- iptables
- allows you to configure network ports and more
lookup current active rules
iptables -L -n -v
remove a rule from IP Tables
iptables -D INPUT 1 or iptables -D INPUT -s 0.0.0.0/0 -p tcp --dport 22 -j ACCEPT
specify policy default
-P INPUT DROP
allow anything from itself (loopback)
-A INPUT -i lo -j ACCEPT
allow connection from specific address, inbound, using only TCP on a specific port
-A INPUT -s ip.address -p tcp --dport 22 -j ACCEPT
add a comment to the iptables rule
-m comment --comment "limit ssh access"
allow related and established
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
prevent packets from forwarding (like a router)
iptables -P FORWARD DROP
delete chain from iptables
iptables -X chain.name
save current IP Tables config
sudo sh -c "iptables-save > /etc/iptables.rules"
restore IP Tables config (also add this line to /etc/rc.local for it to auto run during boot)
iptables-restore < /etc/iptables.rules