Skip to content

Could really use an unban option to the script #13

Open

Description

@erco77

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.

Activity

  1. erco77 commented on Jun 10, 2024

    @erco77
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions