I have a script that adds iptable PREROUTING rules. They all have the same to address. When I run this:
iptables --list PREROUTING -t nat
I see output like this:
DNAT tcp -- anywhere 126.96.36.199 tcp dpt:https to:192.168.2.1:443 DNAT tcp -- anywhere 188.8.131.52 tcp dpt:https to:192.168.2.1:443 DNAT tcp -- anywhere 184.108.40.206 tcp dpt:https to:192.168.2.1:443
It seems like I should be able to drop all these rules by writing a command like this...
"drop all PREROUTING rules that go to 192.168.2.1:443"
So, in looking at the options for itables it looks like I need to use the -D option. But I don't know the rulenum to give it. :-(
So, I probably need to query for existing rules, grep to limit it to destination 192.168.2.1:443, and run -D passing the rulenum for each one. I have no idea how to do that. Any help would be appreciated.