rss logo

How to delete a Netfilter rule with iptables

Netfilter logo

Here's a method to easily delete a rule under the Netfilter firewall with the iptables command.



  • OS : Arch Linux 3.19.2
  • iptables : v1.4.21


List current rules

  • First we list our current rules :
root@host:~# iptables --line-numbers -L -n -v -t filter
  • --line-numbers : give a number for each rules
  • -L : list rules
  • -n : disable DNS resolution
  • -v : verbose
  • -t filter precise the Netfilter table
root@host:~# iptables --line-numbers -L -n
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     all  --              state RELATED,ESTABLISHED
2    ACCEPT     icmp --             
3    ACCEPT     all  --             
4    ACCEPT     udp  --            state NEW udp dpt:5353
5    REJECT     all  --              reject-with icmp-host-prohibited
6    ACCEPT     tcp  --              tcp dpt:22


Here we delete the rule n°6 of the INPUT chain :

root@host:~# iptables -t filter -D INPUT 6
  • -D : delete

We can also delete the same rule using this command :

root@host:~# iptables -D INPUT -m tcp -p tcp --dport 22 -j ACCEPT
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Contact :

contact mail address