iptables


List all Rules

iptables -n -v -L

Whitelist by Source IP

iptables -A INPUT -s 127.0.0.1 -p tcp -j ACCEPT

Allow SSH

iptables -A INPUT -p tcp -m tcp --dport 22 -m conntrack --ctstate NEW,RELATED,ESTABLISHED -j ACCEPT

Set Chain Policy

iptables -P [INPUT | OUTPUT | FORWARD] [ACCEPT | DROP]

Specify Interface (e.g. Loopback)

iptables -A INPUT -i lo -j ACCEPT   # incoming
iptables -A OUTPUT -o lo -j ACCEPT  # outgoing

Load iptables Rules from File

iptables-restore /etc/iptables/rules.v4