iptables remove rules using –line-numbers

List the rules for a specific chain. Example below list the “fail2ban-ssh-ddos” chain.

iptables -L fail2ban-ssh-ddos --line-numbers

Example output:

Chain fail2ban-ssh-ddos (2 references)
num  target     prot opt source               destination
1    REJECT     all  --  192.0.0.8             anywhere             reject-with icmp-port-unreachable
2    RETURN     all  --  anywhere             anywhere

Delete rule line number 1:

iptables -D fail2ban-ssh-ddos 1