In Linux, you can use the iptables
command to manage the firewall rules. To delete a prerouting rule, you can use the -D
option, followed by the table, chain, and rule number.
For example, to delete a prerouting rule in the nat
table, in the PREROUTING
chain, with a rule number of 2
, you would use the following command:
sudo iptables -t nat -D PREROUTING 2
You can also use -D
option with a specific rule you want to delete. For example,
sudo iptables -t nat -D PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
This will delete the rule which redirect incoming traffic on port 80 to port 8080.
You can also use -F
option to flush all the rules in a specific chain or table.
sudo iptables -t nat -F PREROUTING
This will flush all the rules in the PREROUTING
chain of the nat
table.
It’s important to note that these changes will not persist across reboots, If you want to save your iptables rules and make them persist across reboots, you can use the iptables-save
command to save the rules to a file, and then use the iptables-restore
command to restore the rules on boot.