To list the rule list with numbers:
iptables -L-n --line-numbers [root@server ~]# iptables -L INPUT -n --line-numbers Chain INPUT (policy ACCEPT) num target prot opt source destination 1 DROP tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306 2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:555 3 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 [root@server ~]#
iptables -D
[root@server ~]# iptables -D INPUT 1
Result:
[root@server ~]# iptables -L INPUT -n --line-numbers Chain INPUT (policy ACCEPT) num target prot opt source destination 1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:555 2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 [root@server ~]#
Read more »»