To list all iptables rules with line numbers on a Linux system, you can use the iptables
utility with the -L
option.
To list the rules for the filter table, run the following command:
refer to:lautturi.comsudo iptables -L --line-numbers
This will display a list of all rules in the filter table, along with their line numbers.
To list the rules for a different table, use the -t
option followed by the name of the table. For example, to list the rules for the nat table, run the following command:
sudo iptables -L -t nat --line-numbers
This will display a list of all rules in the nat table, along with their line numbers.
To list the rules for a specific chain, use the -n
option followed by the name of the chain. For example, to list the rules for the INPUT chain in the filter table, run the following command:
sudo iptables -L INPUT --line-numbers
This will display a list of all rules in the INPUT chain, along with their line numbers.
That's it! You now have a list of iptables rules with line numbers on your Linux system.