Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could really use an unban option to the script #13

Open
erco77 opened this issue Jun 10, 2024 · 1 comment
Open

Could really use an unban option to the script #13

erco77 opened this issue Jun 10, 2024 · 1 comment

Comments

@erco77
Copy link

erco77 commented Jun 10, 2024

I found after a week or so of blocking AWS, it was preventing https certifications from renewing (letsencrypt.org), causing certbot renew operations to fail with "connection refused" when their "multi-perspective" validation checks tried to come in from different locations to verify our webserver, some of which are apparently AWS originated and REJECT'ed.

It'd be good if there was a simple option to the script to 'unban' all the AWS chains.

@erco77
Copy link
Author

erco77 commented Jun 10, 2024

Hmm, it looks like the script is creating all the blocks with the chain name "AWS", and it at first looked like it'd be easy to just use iptables -X AWS or iptables --delete-chain AWS to remove them, but I guess there's so many, iptables has a problem removing them:

# iptables -X AWS
iptables: Too many links.

What does seem to work to remove all the AWS quickly/efficiently is this:

iptables-save     > /tmp/iptables.txt      -- save the current ipv4 tables
ip6tables-save    > /tmp/ip6tables.txt     -- save the current ipv6 tables
sed -i '/AWS/d'     /tmp/iptables.txt      -- remove all the AWS ip4v entries
sed -i '/AWS/d'     /tmp/ip6tables.txt     -- remove all the AWS ipv6 entries
iptables-restore  < /tmp/iptables.txt      -- apply changes with AWS entries removed
ip6tables-restore < /tmp/ip6tables.txt     -- apply changes with AWS entries removed

..so something like that could probably be added to the script as an 'unban' option flag.

For web admins needing to fix problems with renewing https certs caused by the AWS block, one can just completely clear the firewall using iptables -F and ip6tables -F (in place of the above sed commands), run the recert commands with the firewall cleared (e.g. certbot renew), then use the iptables-restore / ip6tables-restore commands to bring back the firewall config exactly the way it was, which preserves any 'fail2ban' blocks too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant