Iptables

From LocalizationWiki

To check the existing rules

iptables -L

To check the packages being blocked for that IP address

iptables -L -v

To check the rule numbers inside the iptables

iptables -L --line-numbers

To create a new Chain

iptables -N Any-Chain-name

Blocking the IP addresses

iptables -A Any-Chain-name -s 192.168.0.187 -j REJECT

To use the new chain created above

iptables -I FORWARD 1 -j Any-Chain-name
iptables -I INPUT 1 -j Any-Chain-name

To delete the above chain rules

iptables -D FORWARD 1
iptables -D INPUT 1

To delete the rules under the chain

iptables -D Any-Chain-name 1

To delete the Chain

iptables -X Any-Chain-name