iptables / nftables Commands
Linux packet filtering.All iptables / nftables pages
- iptables -D: delete a rule by number or by specificationDelete an iptables rule with -D by its line number or by the exact specification from iptables -S. Shifting numbers, flushing chains, errors and persistence.
- iptables -L -n -v --line-numbers: list rules with counters and numberssudo iptables -L -n -v --line-numbers lists rules with counters and numbers. Read the output, list the nat table, and delete or insert rules by their number.
- iptables block an IP address: iptables -I INPUT -s 203.0.113.7 -j DROPBlock an IP address with iptables -I INPUT -s ADDR -j DROP. Why insert beats append, DROP vs REJECT, ranges, ipset for long lists, Docker and IPv6 notes.
- Save iptables rules permanently: iptables-save, iptables-restore and persistence after rebootiptables rules vanish at reboot. Save with iptables-save, load with iptables-restore, and persist them with netfilter-persistent on Debian or iptables-services.