Skip to main content

fail2bangeolocation

Shows geolocation of failed attempts registered by fail2ban.
It's useful to know from which locations you are being attacked the most.
You can group locations by country or by country and by city.

GitHub repo file count GitHub code size in bytes GitHub repo size

PyPI PyPI - Python Version PyPI - Implementation PyPI - Wheel PyPI - Downloads

GitHub issues GitHub closed issues GitHub pull requests GitHub closed pull requests GitHub all releases

GitHub

Screenshots

  • Grouped by country
Output grouped by country
  • Grouped by country and city
Output grouped by country and city

reallyfreegeoip.org

IP geolocation is done through reallyfreegeoip.org. This means you will need an active internet connection in order to geolocate the IPs.

Installation

You can install fail2bangeolocation via pipx:

Installation as user

$ pipx install fail2bangeolocation

Installation as root

$ sudo su
# pipx install fail2bangeolocation

Usage

  • You can run fail2bangeolocation directly from the command line interface:

    fail2bangeolocation [-h] [-c] {fail2ban,log,server}
    
  • fail2bangeolocation arguments

    usage: fail2bangeolocation.py [-h] [-c] {fail2ban,log,server} ...
    
    Shows geolocation of failed attempts registered by fail2ban
    
    positional arguments:
      {fail2ban,log,server}
                            These options are mutually exclusive
        fail2ban            analyze all banned IPs by fail2ban (from fail2ban output)
        log                 analyze a fail2ban log file. Use "log -h" to see more options
        server              analyze all banned IPs by fail2ban (e.g. "server sshd")
    
    optional arguments:
      -h, --help            show this help message and exit
      -c, --show-city       group IPs by country and city 
    
  • Analyze all IPs registered by fail2ban

    ⚠️ Requires root privileges

    Run fail2bangeolocation using the fail2ban argument:

    $ sudo su
    # fail2bangeolocation fail2ban
    
  • Analyze all IPs registered by fail2ban for a given jailed server/service, e.g. sshd

    ⚠️ Requires root privileges
    Run fail2bangeolocation with the server argument and the jailed server name:

    $sudo su
    # fail2bangeolocation server sshd
    
  • Analyze a log file

    ⚠️ May require root privileges depending on the file to be analyzed
    Run fail2bangeolocation with the log argument and the path to the log file:

    fail2bangeolocation log /var/log/fai2ban.log
    

    You can also geolocate the unbanned IPs contained in the log adding the -u argument:

    fail2bangeolocation log -u /var/log/fai2ban.log
    
  • Group the output by country and city

    Run fail2bangeolocation with "-c" as first argument:

    fail2bangeolocation -c {fail2ban,log,server}
    

Troubleshooting

In case of any problem, you create an issue.

Discussions

If you want ask (or answer) a question, leave an opinion or have an open-ended conversation you can create (or join) a discussion.

Support

If you find this application useful you can star this repo.

Metadata

Release files for fail2bangeolocation 2.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fail2bangeolocation 2.0.9
File Size Uploaded
fail2bangeolocation-2.0.9.tar.gz 57.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fail2bangeolocation 2.0.9
File Interpreter ABI Platform
fail2bangeolocation-2.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 96.3 kB

Release files / fail2bangeolocation-2.0.9.tar.gz

Download URL fail2bangeolocation-2.0.9.tar.gz
Size 57.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cee5c7cb59e6b6906b817417b2e5d74c506af3f752e70cadb3d8996b5d9ff021
BLAKE2b-256 checksum
How to use checksums
b5a166a456a9c2070d19e4f44cb65634d2748dd9e60c4d679fb1a17368fb2848
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2024.

Transparency log

Release files / fail2bangeolocation-2.0.9-py3-none-any.whl

Download URL fail2bangeolocation-2.0.9-py3-none-any.whl
Size 38.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab184aaaa6ef532eb6723056573e8d895ddc5e2b695caaf9e9ec888e57196f7d
BLAKE2b-256 checksum
How to use checksums
af253e1ad0f2ca998a3647e1a6e8b44d103f1695426710c4ea07f56f43ec3542
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2024.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.9 This release

2 release files

2.0.8

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page