I have an ubuntu server which only allows traffic on a select group of ports via iptables. One of the ports that is set to
REJECT by default is
I need to periodically open port 53 to run an instance of
acme-dns to authenticate
DNS-01 challenges from LetsEncrypt, then close it when finished.
Is there an easy way this can be automated? I know how to easily automate adding a rule via
iptables -I to insert an
53 at the top of the list, but the only way I know how to disable a particular rule is to list all active rules with line numbers and disable the particular rule by line number. That requires manual interaction on my part.
I need remove that rule, and not undo it by inserting a
REJECT before it, because this will be run by a cron job and I don't want pollute the rules with a bunch of ACCEPT/REJECT toggles that undo one another.
The only approach I can think of is to write a script that prints the rules by line number, analyzes them, then drops the matching rule. Is there a way to do this simply with an iptables command that I don't know of?