Hello. I'm brand new to Linux, but a long time Windows administrator, so I understand the concepts, not the syntax.

I've stumbled through setting up Ubuntu Server as a NAT server. It's working great now.

My goal is to map public IPs to private IPs. However, I want to change them often through an automated fashion (SSH remote call). So, I want to run commands that will remove the previous rule and add a new rule, or update the existing rule.

For example, the original rule may be something like:
iptables -t nat -I PREROUTING -d -j DNAT --to-destination
iptables -t nat -I POSTROUTING -s -j SNAT --to-source

The issue I'm running into is finding out how to delete the previous entry before adding a new one. For example, let's say that should now map to (instead of .5).

Is there a wildcard option for the delete rule so that I don't need to know the original destination IP? i.e.
iptables -t nat -D PREROUTING -d -j DNAT --to-destination [+]

Or, would it make sense to create a script that traverses all rules, gets the existing rule, and then deletes it?

Of course my next issue would be that I don't know any Linux scripting so it's hard to know where to start.