I am using ansible to configure ufw on my DB servers to only let accept connections from certain servers connection to a specific port (lets say
When a server that used to have access is taken out of the pool, it might be forgotten to remove the access rule for that server.
My solution: When setting up the rules, I want to delete all rules for port
1234, and then recreate them with the servers from the current pool.
ufw delete requires to precisely specify the rule to be deleted (port,protocol, scr IP,...).
I tried a solution like
ufw delete $(ufw status numbered | grep 1234 | <get all the numbers of the rules> ), but it got really ugly, really fast.
Is there a better way to delete all rules for a certain port?