I would recommend that you save your existing rules before making your adjustment, and then restoring those rules once you're done using the special rule.
iptables-save > /etc/iptables.rules
iptables -t nat -I PREROUTING -i eno1 -p TCP -d 22.214.171.124/32 --dport 2020 -j DNAT --to-destination 10.167.147.211:2020
- Do your thing.
iptables-restore < /etc/iptables.rules
This would be especially useful if you have other iptables rules (such as those from
Another option is to save your iptables to a file as described above, except instead of manually flushing and restoring, you could set up
/etc/network/if-pre-up.d/ to restore, and have
/etc/network/if-post-down.d/ flush. This way, you could just do something such as
ifdown eth0 && ifup eth0 to get back to where you started.
This question may be helpful.