iptables examples


Block incoming connections for specific port

Block incoming port (8888) for remote adresses except localhost:
iptables -A INPUT -i lo -p tcp -s localhost --dport 8888 -j ACCEPT
iptables -A INPUT -p tcp --dport 8888 -j DROP

Remove "incoming" rules

First, check line numbers:
iptables -L INPUT -n --line-numbers
Then remove specific line:
sudo iptables -D INPUT (number)

<< BACK