Delete all fail2ban bans in Ubuntu Linux












7














How can I delete all fail2ban bans in Ubuntu?
I tried everything but I don't get it.



I just want to delete all bans - but I don't know any IP adresses.










share|improve this question




















  • 1




    The bans are typically done on IP addresses through your firewall, so you should look at the firewall rules.
    – Julie Pelletier
    May 28 '16 at 14:45










  • yes i know. but i want to clear all bans without telling a ip adress
    – Patrick
    May 28 '16 at 15:14
















7














How can I delete all fail2ban bans in Ubuntu?
I tried everything but I don't get it.



I just want to delete all bans - but I don't know any IP adresses.










share|improve this question




















  • 1




    The bans are typically done on IP addresses through your firewall, so you should look at the firewall rules.
    – Julie Pelletier
    May 28 '16 at 14:45










  • yes i know. but i want to clear all bans without telling a ip adress
    – Patrick
    May 28 '16 at 15:14














7












7








7


2





How can I delete all fail2ban bans in Ubuntu?
I tried everything but I don't get it.



I just want to delete all bans - but I don't know any IP adresses.










share|improve this question















How can I delete all fail2ban bans in Ubuntu?
I tried everything but I don't get it.



I just want to delete all bans - but I don't know any IP adresses.







fail2ban






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 28 '16 at 17:13









Jeff Schaller

38.7k1053125




38.7k1053125










asked May 28 '16 at 14:42









Patrick

46112




46112








  • 1




    The bans are typically done on IP addresses through your firewall, so you should look at the firewall rules.
    – Julie Pelletier
    May 28 '16 at 14:45










  • yes i know. but i want to clear all bans without telling a ip adress
    – Patrick
    May 28 '16 at 15:14














  • 1




    The bans are typically done on IP addresses through your firewall, so you should look at the firewall rules.
    – Julie Pelletier
    May 28 '16 at 14:45










  • yes i know. but i want to clear all bans without telling a ip adress
    – Patrick
    May 28 '16 at 15:14








1




1




The bans are typically done on IP addresses through your firewall, so you should look at the firewall rules.
– Julie Pelletier
May 28 '16 at 14:45




The bans are typically done on IP addresses through your firewall, so you should look at the firewall rules.
– Julie Pelletier
May 28 '16 at 14:45












yes i know. but i want to clear all bans without telling a ip adress
– Patrick
May 28 '16 at 15:14




yes i know. but i want to clear all bans without telling a ip adress
– Patrick
May 28 '16 at 15:14










7 Answers
7






active

oldest

votes


















10














Updated answer



As of version 0.10.0 fail2ban-client features the unban command that can be used in two ways:



unban --all                              unbans all IP addresses (in all
jails and database)
unban <IP> ... <IP> unbans <IP> (in all jails and
database)


Moreover, the restart <JAIL>, reload <JAIL> and reload commands now also have the --unban option.



Old Answer



fail2ban uses iptables to block traffic. If you would want to see the IP addresses that are currently blocked, type



iptables -L -n


and look for the various chains named fail2ban-something, where something points to the fail2ban jail (for instance, Chain f2b-sshd refers to the jail sshd).
If you only want to remove the block for a single IP address <IP> for a given jail <JAIL>, fail2ban offers its own client:



fail2ban-client set <JAIL> unbanip <IP>


Alternatively you can use line numbers. First, list the iptables rules with line numbers:



iptables -L -n --line-numbers


Next you can use



iptables -D fail2ban-somejail <linenumber> 


to remove a single line from the table. As far as I know there is no option to select a range of line numbers, so I guess you would have to wrap this command in a for loop:



for lin in {200..1}; do
iptables -D fail2ban-somejail $lin
done


Here I made the number 200 up. Check your own output of the command with --line-numbers and note that the last line (with RETURN) should stay. See @roaima's comment below for the reasoning behind counting down.






share|improve this answer



















  • 1




    Careful with that loop. When you delete the first rule, the second one becomes first (if you see what I mean). So either count down from N to 1, or delete the first rule N times: for lin in {1..200}; do iptables -D fail2ban-somejail 1; done
    – roaima
    Dec 20 at 8:50












  • Thanks @roaima! I'll update the answer accordingly.
    – ph0t0nix
    Dec 20 at 8:57






  • 1




    @roaima Yes it is (at least in zsh and bash): echo {5..1} will result in 5 4 3 2 1 .
    – ph0t0nix
    Dec 20 at 9:24



















7














The best way to unban all IPs, is to set the bantime to 1 second, then all the IP will be freed right away.



fail2ban-client set JailName bantime 1


After that you can set the proper ban time back.



It's better to let fail2ban to do the unban for you. Don't manually edit iptables yourself.






share|improve this answer























  • This is the only correct answer here. Fail2ban maintains its own ban database that must be cleared independently. Every answer talking about deleting iptables rules ignores that the moment fail2ban is started back up it will re-add the rules you just deleted back to iptables. Also, not every fail2ban configuration uses iptables to implement bans.
    – Cliff Armstrong
    Jan 24 at 10:56








  • 1




    find all jails with fail2ban-client status
    – Flion
    Jul 16 at 18:12



















2














Save iptable config to file



$ iptables-save > iptables.conf


Edit it with any editor you like
Than load config back to iptables



$ iptables-restore < iptables.conf


Do not forget to store configuration inside iptables so it will be picked up on reboot



$ service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]





share|improve this answer





















  • This is one of the way one could do this. Thanks.
    – User9102d82
    Jul 15 '17 at 18:51



















1














Because of the way fail2ban works, there are only two possible solutions:




  • Make a firewall configuration script that includes fail2ban jails and restart the firewall.

  • Remove the firewall rules blocking the IPs that you wish to unban.






share|improve this answer





























    1














    1. stopping the service will clean all rules added by fail2ban



    service fail2ban stop



    2. if you do not have any other iptables rules, you can flush it



    iptables -F



    be careful: this will erase any other rules in your iptables.






    share|improve this answer































      1














      The latest fail2ban-client (0.10) has a unban -all command. Jails can also be individually "restarted", effectively clearing the bans.



      If you have an older version, this trick might work for automatic temporary bans: delete the jail which contains the ban then restart fail2ban so that the (now empty) jail would be recreated.



      $ fail2ban-client stop sshd
      Jail stopped
      $ systemctl restart fail2ban





      share|improve this answer































        0














        heres a simple oneliner to unban the whole fail2ban jail the proper way:



        iptables -L f2b-recidive -n | grep -o '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' | grep -v 0.0.0.0 | xargs -n 1 fail2ban-client set recidive unbanip


        NOTE: iptables command takes "f2b-" prefix before the jail name while "fail2ban-client" the real jail name






        share|improve this answer





















          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f286119%2fdelete-all-fail2ban-bans-in-ubuntu-linux%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          7 Answers
          7






          active

          oldest

          votes








          7 Answers
          7






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          10














          Updated answer



          As of version 0.10.0 fail2ban-client features the unban command that can be used in two ways:



          unban --all                              unbans all IP addresses (in all
          jails and database)
          unban <IP> ... <IP> unbans <IP> (in all jails and
          database)


          Moreover, the restart <JAIL>, reload <JAIL> and reload commands now also have the --unban option.



          Old Answer



          fail2ban uses iptables to block traffic. If you would want to see the IP addresses that are currently blocked, type



          iptables -L -n


          and look for the various chains named fail2ban-something, where something points to the fail2ban jail (for instance, Chain f2b-sshd refers to the jail sshd).
          If you only want to remove the block for a single IP address <IP> for a given jail <JAIL>, fail2ban offers its own client:



          fail2ban-client set <JAIL> unbanip <IP>


          Alternatively you can use line numbers. First, list the iptables rules with line numbers:



          iptables -L -n --line-numbers


          Next you can use



          iptables -D fail2ban-somejail <linenumber> 


          to remove a single line from the table. As far as I know there is no option to select a range of line numbers, so I guess you would have to wrap this command in a for loop:



          for lin in {200..1}; do
          iptables -D fail2ban-somejail $lin
          done


          Here I made the number 200 up. Check your own output of the command with --line-numbers and note that the last line (with RETURN) should stay. See @roaima's comment below for the reasoning behind counting down.






          share|improve this answer



















          • 1




            Careful with that loop. When you delete the first rule, the second one becomes first (if you see what I mean). So either count down from N to 1, or delete the first rule N times: for lin in {1..200}; do iptables -D fail2ban-somejail 1; done
            – roaima
            Dec 20 at 8:50












          • Thanks @roaima! I'll update the answer accordingly.
            – ph0t0nix
            Dec 20 at 8:57






          • 1




            @roaima Yes it is (at least in zsh and bash): echo {5..1} will result in 5 4 3 2 1 .
            – ph0t0nix
            Dec 20 at 9:24
















          10














          Updated answer



          As of version 0.10.0 fail2ban-client features the unban command that can be used in two ways:



          unban --all                              unbans all IP addresses (in all
          jails and database)
          unban <IP> ... <IP> unbans <IP> (in all jails and
          database)


          Moreover, the restart <JAIL>, reload <JAIL> and reload commands now also have the --unban option.



          Old Answer



          fail2ban uses iptables to block traffic. If you would want to see the IP addresses that are currently blocked, type



          iptables -L -n


          and look for the various chains named fail2ban-something, where something points to the fail2ban jail (for instance, Chain f2b-sshd refers to the jail sshd).
          If you only want to remove the block for a single IP address <IP> for a given jail <JAIL>, fail2ban offers its own client:



          fail2ban-client set <JAIL> unbanip <IP>


          Alternatively you can use line numbers. First, list the iptables rules with line numbers:



          iptables -L -n --line-numbers


          Next you can use



          iptables -D fail2ban-somejail <linenumber> 


          to remove a single line from the table. As far as I know there is no option to select a range of line numbers, so I guess you would have to wrap this command in a for loop:



          for lin in {200..1}; do
          iptables -D fail2ban-somejail $lin
          done


          Here I made the number 200 up. Check your own output of the command with --line-numbers and note that the last line (with RETURN) should stay. See @roaima's comment below for the reasoning behind counting down.






          share|improve this answer



















          • 1




            Careful with that loop. When you delete the first rule, the second one becomes first (if you see what I mean). So either count down from N to 1, or delete the first rule N times: for lin in {1..200}; do iptables -D fail2ban-somejail 1; done
            – roaima
            Dec 20 at 8:50












          • Thanks @roaima! I'll update the answer accordingly.
            – ph0t0nix
            Dec 20 at 8:57






          • 1




            @roaima Yes it is (at least in zsh and bash): echo {5..1} will result in 5 4 3 2 1 .
            – ph0t0nix
            Dec 20 at 9:24














          10












          10








          10






          Updated answer



          As of version 0.10.0 fail2ban-client features the unban command that can be used in two ways:



          unban --all                              unbans all IP addresses (in all
          jails and database)
          unban <IP> ... <IP> unbans <IP> (in all jails and
          database)


          Moreover, the restart <JAIL>, reload <JAIL> and reload commands now also have the --unban option.



          Old Answer



          fail2ban uses iptables to block traffic. If you would want to see the IP addresses that are currently blocked, type



          iptables -L -n


          and look for the various chains named fail2ban-something, where something points to the fail2ban jail (for instance, Chain f2b-sshd refers to the jail sshd).
          If you only want to remove the block for a single IP address <IP> for a given jail <JAIL>, fail2ban offers its own client:



          fail2ban-client set <JAIL> unbanip <IP>


          Alternatively you can use line numbers. First, list the iptables rules with line numbers:



          iptables -L -n --line-numbers


          Next you can use



          iptables -D fail2ban-somejail <linenumber> 


          to remove a single line from the table. As far as I know there is no option to select a range of line numbers, so I guess you would have to wrap this command in a for loop:



          for lin in {200..1}; do
          iptables -D fail2ban-somejail $lin
          done


          Here I made the number 200 up. Check your own output of the command with --line-numbers and note that the last line (with RETURN) should stay. See @roaima's comment below for the reasoning behind counting down.






          share|improve this answer














          Updated answer



          As of version 0.10.0 fail2ban-client features the unban command that can be used in two ways:



          unban --all                              unbans all IP addresses (in all
          jails and database)
          unban <IP> ... <IP> unbans <IP> (in all jails and
          database)


          Moreover, the restart <JAIL>, reload <JAIL> and reload commands now also have the --unban option.



          Old Answer



          fail2ban uses iptables to block traffic. If you would want to see the IP addresses that are currently blocked, type



          iptables -L -n


          and look for the various chains named fail2ban-something, where something points to the fail2ban jail (for instance, Chain f2b-sshd refers to the jail sshd).
          If you only want to remove the block for a single IP address <IP> for a given jail <JAIL>, fail2ban offers its own client:



          fail2ban-client set <JAIL> unbanip <IP>


          Alternatively you can use line numbers. First, list the iptables rules with line numbers:



          iptables -L -n --line-numbers


          Next you can use



          iptables -D fail2ban-somejail <linenumber> 


          to remove a single line from the table. As far as I know there is no option to select a range of line numbers, so I guess you would have to wrap this command in a for loop:



          for lin in {200..1}; do
          iptables -D fail2ban-somejail $lin
          done


          Here I made the number 200 up. Check your own output of the command with --line-numbers and note that the last line (with RETURN) should stay. See @roaima's comment below for the reasoning behind counting down.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 20 at 8:56

























          answered May 28 '16 at 15:46









          ph0t0nix

          517417




          517417








          • 1




            Careful with that loop. When you delete the first rule, the second one becomes first (if you see what I mean). So either count down from N to 1, or delete the first rule N times: for lin in {1..200}; do iptables -D fail2ban-somejail 1; done
            – roaima
            Dec 20 at 8:50












          • Thanks @roaima! I'll update the answer accordingly.
            – ph0t0nix
            Dec 20 at 8:57






          • 1




            @roaima Yes it is (at least in zsh and bash): echo {5..1} will result in 5 4 3 2 1 .
            – ph0t0nix
            Dec 20 at 9:24














          • 1




            Careful with that loop. When you delete the first rule, the second one becomes first (if you see what I mean). So either count down from N to 1, or delete the first rule N times: for lin in {1..200}; do iptables -D fail2ban-somejail 1; done
            – roaima
            Dec 20 at 8:50












          • Thanks @roaima! I'll update the answer accordingly.
            – ph0t0nix
            Dec 20 at 8:57






          • 1




            @roaima Yes it is (at least in zsh and bash): echo {5..1} will result in 5 4 3 2 1 .
            – ph0t0nix
            Dec 20 at 9:24








          1




          1




          Careful with that loop. When you delete the first rule, the second one becomes first (if you see what I mean). So either count down from N to 1, or delete the first rule N times: for lin in {1..200}; do iptables -D fail2ban-somejail 1; done
          – roaima
          Dec 20 at 8:50






          Careful with that loop. When you delete the first rule, the second one becomes first (if you see what I mean). So either count down from N to 1, or delete the first rule N times: for lin in {1..200}; do iptables -D fail2ban-somejail 1; done
          – roaima
          Dec 20 at 8:50














          Thanks @roaima! I'll update the answer accordingly.
          – ph0t0nix
          Dec 20 at 8:57




          Thanks @roaima! I'll update the answer accordingly.
          – ph0t0nix
          Dec 20 at 8:57




          1




          1




          @roaima Yes it is (at least in zsh and bash): echo {5..1} will result in 5 4 3 2 1 .
          – ph0t0nix
          Dec 20 at 9:24




          @roaima Yes it is (at least in zsh and bash): echo {5..1} will result in 5 4 3 2 1 .
          – ph0t0nix
          Dec 20 at 9:24













          7














          The best way to unban all IPs, is to set the bantime to 1 second, then all the IP will be freed right away.



          fail2ban-client set JailName bantime 1


          After that you can set the proper ban time back.



          It's better to let fail2ban to do the unban for you. Don't manually edit iptables yourself.






          share|improve this answer























          • This is the only correct answer here. Fail2ban maintains its own ban database that must be cleared independently. Every answer talking about deleting iptables rules ignores that the moment fail2ban is started back up it will re-add the rules you just deleted back to iptables. Also, not every fail2ban configuration uses iptables to implement bans.
            – Cliff Armstrong
            Jan 24 at 10:56








          • 1




            find all jails with fail2ban-client status
            – Flion
            Jul 16 at 18:12
















          7














          The best way to unban all IPs, is to set the bantime to 1 second, then all the IP will be freed right away.



          fail2ban-client set JailName bantime 1


          After that you can set the proper ban time back.



          It's better to let fail2ban to do the unban for you. Don't manually edit iptables yourself.






          share|improve this answer























          • This is the only correct answer here. Fail2ban maintains its own ban database that must be cleared independently. Every answer talking about deleting iptables rules ignores that the moment fail2ban is started back up it will re-add the rules you just deleted back to iptables. Also, not every fail2ban configuration uses iptables to implement bans.
            – Cliff Armstrong
            Jan 24 at 10:56








          • 1




            find all jails with fail2ban-client status
            – Flion
            Jul 16 at 18:12














          7












          7








          7






          The best way to unban all IPs, is to set the bantime to 1 second, then all the IP will be freed right away.



          fail2ban-client set JailName bantime 1


          After that you can set the proper ban time back.



          It's better to let fail2ban to do the unban for you. Don't manually edit iptables yourself.






          share|improve this answer














          The best way to unban all IPs, is to set the bantime to 1 second, then all the IP will be freed right away.



          fail2ban-client set JailName bantime 1


          After that you can set the proper ban time back.



          It's better to let fail2ban to do the unban for you. Don't manually edit iptables yourself.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 10 '17 at 4:51









          peterh

          4,28592957




          4,28592957










          answered Nov 10 '17 at 3:13









          Philip

          7111




          7111












          • This is the only correct answer here. Fail2ban maintains its own ban database that must be cleared independently. Every answer talking about deleting iptables rules ignores that the moment fail2ban is started back up it will re-add the rules you just deleted back to iptables. Also, not every fail2ban configuration uses iptables to implement bans.
            – Cliff Armstrong
            Jan 24 at 10:56








          • 1




            find all jails with fail2ban-client status
            – Flion
            Jul 16 at 18:12


















          • This is the only correct answer here. Fail2ban maintains its own ban database that must be cleared independently. Every answer talking about deleting iptables rules ignores that the moment fail2ban is started back up it will re-add the rules you just deleted back to iptables. Also, not every fail2ban configuration uses iptables to implement bans.
            – Cliff Armstrong
            Jan 24 at 10:56








          • 1




            find all jails with fail2ban-client status
            – Flion
            Jul 16 at 18:12
















          This is the only correct answer here. Fail2ban maintains its own ban database that must be cleared independently. Every answer talking about deleting iptables rules ignores that the moment fail2ban is started back up it will re-add the rules you just deleted back to iptables. Also, not every fail2ban configuration uses iptables to implement bans.
          – Cliff Armstrong
          Jan 24 at 10:56






          This is the only correct answer here. Fail2ban maintains its own ban database that must be cleared independently. Every answer talking about deleting iptables rules ignores that the moment fail2ban is started back up it will re-add the rules you just deleted back to iptables. Also, not every fail2ban configuration uses iptables to implement bans.
          – Cliff Armstrong
          Jan 24 at 10:56






          1




          1




          find all jails with fail2ban-client status
          – Flion
          Jul 16 at 18:12




          find all jails with fail2ban-client status
          – Flion
          Jul 16 at 18:12











          2














          Save iptable config to file



          $ iptables-save > iptables.conf


          Edit it with any editor you like
          Than load config back to iptables



          $ iptables-restore < iptables.conf


          Do not forget to store configuration inside iptables so it will be picked up on reboot



          $ service iptables save
          iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]





          share|improve this answer





















          • This is one of the way one could do this. Thanks.
            – User9102d82
            Jul 15 '17 at 18:51
















          2














          Save iptable config to file



          $ iptables-save > iptables.conf


          Edit it with any editor you like
          Than load config back to iptables



          $ iptables-restore < iptables.conf


          Do not forget to store configuration inside iptables so it will be picked up on reboot



          $ service iptables save
          iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]





          share|improve this answer





















          • This is one of the way one could do this. Thanks.
            – User9102d82
            Jul 15 '17 at 18:51














          2












          2








          2






          Save iptable config to file



          $ iptables-save > iptables.conf


          Edit it with any editor you like
          Than load config back to iptables



          $ iptables-restore < iptables.conf


          Do not forget to store configuration inside iptables so it will be picked up on reboot



          $ service iptables save
          iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]





          share|improve this answer












          Save iptable config to file



          $ iptables-save > iptables.conf


          Edit it with any editor you like
          Than load config back to iptables



          $ iptables-restore < iptables.conf


          Do not forget to store configuration inside iptables so it will be picked up on reboot



          $ service iptables save
          iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 27 '17 at 7:31









          Subdigger

          1213




          1213












          • This is one of the way one could do this. Thanks.
            – User9102d82
            Jul 15 '17 at 18:51


















          • This is one of the way one could do this. Thanks.
            – User9102d82
            Jul 15 '17 at 18:51
















          This is one of the way one could do this. Thanks.
          – User9102d82
          Jul 15 '17 at 18:51




          This is one of the way one could do this. Thanks.
          – User9102d82
          Jul 15 '17 at 18:51











          1














          Because of the way fail2ban works, there are only two possible solutions:




          • Make a firewall configuration script that includes fail2ban jails and restart the firewall.

          • Remove the firewall rules blocking the IPs that you wish to unban.






          share|improve this answer


























            1














            Because of the way fail2ban works, there are only two possible solutions:




            • Make a firewall configuration script that includes fail2ban jails and restart the firewall.

            • Remove the firewall rules blocking the IPs that you wish to unban.






            share|improve this answer
























              1












              1








              1






              Because of the way fail2ban works, there are only two possible solutions:




              • Make a firewall configuration script that includes fail2ban jails and restart the firewall.

              • Remove the firewall rules blocking the IPs that you wish to unban.






              share|improve this answer












              Because of the way fail2ban works, there are only two possible solutions:




              • Make a firewall configuration script that includes fail2ban jails and restart the firewall.

              • Remove the firewall rules blocking the IPs that you wish to unban.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered May 28 '16 at 17:10









              Julie Pelletier

              6,96211340




              6,96211340























                  1














                  1. stopping the service will clean all rules added by fail2ban



                  service fail2ban stop



                  2. if you do not have any other iptables rules, you can flush it



                  iptables -F



                  be careful: this will erase any other rules in your iptables.






                  share|improve this answer




























                    1














                    1. stopping the service will clean all rules added by fail2ban



                    service fail2ban stop



                    2. if you do not have any other iptables rules, you can flush it



                    iptables -F



                    be careful: this will erase any other rules in your iptables.






                    share|improve this answer


























                      1












                      1








                      1






                      1. stopping the service will clean all rules added by fail2ban



                      service fail2ban stop



                      2. if you do not have any other iptables rules, you can flush it



                      iptables -F



                      be careful: this will erase any other rules in your iptables.






                      share|improve this answer














                      1. stopping the service will clean all rules added by fail2ban



                      service fail2ban stop



                      2. if you do not have any other iptables rules, you can flush it



                      iptables -F



                      be careful: this will erase any other rules in your iptables.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Mar 14 at 19:08









                      peterh

                      4,28592957




                      4,28592957










                      answered Jul 25 '17 at 13:46









                      RASG

                      1293




                      1293























                          1














                          The latest fail2ban-client (0.10) has a unban -all command. Jails can also be individually "restarted", effectively clearing the bans.



                          If you have an older version, this trick might work for automatic temporary bans: delete the jail which contains the ban then restart fail2ban so that the (now empty) jail would be recreated.



                          $ fail2ban-client stop sshd
                          Jail stopped
                          $ systemctl restart fail2ban





                          share|improve this answer




























                            1














                            The latest fail2ban-client (0.10) has a unban -all command. Jails can also be individually "restarted", effectively clearing the bans.



                            If you have an older version, this trick might work for automatic temporary bans: delete the jail which contains the ban then restart fail2ban so that the (now empty) jail would be recreated.



                            $ fail2ban-client stop sshd
                            Jail stopped
                            $ systemctl restart fail2ban





                            share|improve this answer


























                              1












                              1








                              1






                              The latest fail2ban-client (0.10) has a unban -all command. Jails can also be individually "restarted", effectively clearing the bans.



                              If you have an older version, this trick might work for automatic temporary bans: delete the jail which contains the ban then restart fail2ban so that the (now empty) jail would be recreated.



                              $ fail2ban-client stop sshd
                              Jail stopped
                              $ systemctl restart fail2ban





                              share|improve this answer














                              The latest fail2ban-client (0.10) has a unban -all command. Jails can also be individually "restarted", effectively clearing the bans.



                              If you have an older version, this trick might work for automatic temporary bans: delete the jail which contains the ban then restart fail2ban so that the (now empty) jail would be recreated.



                              $ fail2ban-client stop sshd
                              Jail stopped
                              $ systemctl restart fail2ban






                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Dec 23 at 12:27

























                              answered Dec 17 at 17:06









                              Rolf

                              144111




                              144111























                                  0














                                  heres a simple oneliner to unban the whole fail2ban jail the proper way:



                                  iptables -L f2b-recidive -n | grep -o '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' | grep -v 0.0.0.0 | xargs -n 1 fail2ban-client set recidive unbanip


                                  NOTE: iptables command takes "f2b-" prefix before the jail name while "fail2ban-client" the real jail name






                                  share|improve this answer


























                                    0














                                    heres a simple oneliner to unban the whole fail2ban jail the proper way:



                                    iptables -L f2b-recidive -n | grep -o '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' | grep -v 0.0.0.0 | xargs -n 1 fail2ban-client set recidive unbanip


                                    NOTE: iptables command takes "f2b-" prefix before the jail name while "fail2ban-client" the real jail name






                                    share|improve this answer
























                                      0












                                      0








                                      0






                                      heres a simple oneliner to unban the whole fail2ban jail the proper way:



                                      iptables -L f2b-recidive -n | grep -o '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' | grep -v 0.0.0.0 | xargs -n 1 fail2ban-client set recidive unbanip


                                      NOTE: iptables command takes "f2b-" prefix before the jail name while "fail2ban-client" the real jail name






                                      share|improve this answer












                                      heres a simple oneliner to unban the whole fail2ban jail the proper way:



                                      iptables -L f2b-recidive -n | grep -o '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' | grep -v 0.0.0.0 | xargs -n 1 fail2ban-client set recidive unbanip


                                      NOTE: iptables command takes "f2b-" prefix before the jail name while "fail2ban-client" the real jail name







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Sep 12 at 15:27









                                      Vedran B

                                      1




                                      1






























                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Unix & Linux Stack Exchange!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.





                                          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                          Please pay close attention to the following guidance:


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f286119%2fdelete-all-fail2ban-bans-in-ubuntu-linux%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Morgemoulin

                                          Scott Moir

                                          Souastre