Skip to content

vv198x/go2ban

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ go2ban

License: GPL v3 Coverage Go Reference Go Report Card Go Version

Powerful VDS/VPS protection system against brute force attacks, scanners and DDoS


🌍 Why is go2ban important today?

πŸ“Š Shocking statistics: More than 50% of all internet traffic consists of hacker bots, password crackers, and automated vulnerability scanners. Every day, thousands of servers are attacked, leading to enormous losses of computational resources and administrators' time.

go2ban is a modern solution for protecting your servers that not only blocks attackers but also significantly saves computational power, making the internet safer for everyone.

🎯 Key advantages

  • ⚑ Instant blocking in iptables raw table
  • πŸ” Smart monitoring of service logs and Docker containers
  • 🎣 Trap ports for automatic scanner detection
  • 🌐 REST API and gRPC for integration with your systems
  • πŸ“ˆ Resource savings β€” up to 70% reduction in CPU load
  • πŸ›‘οΈ Whitelist for trusted IP addresses

πŸš€ Quick Installation (Recommended)

For the easiest installation experience, use the automated installation script:

# Clone the repository
git clone https://github.com/vv198x/go2ban.git
cd go2ban

# Run the installation
chmod +x install.sh
./install.sh

✨ What the script does automatically:

  • βœ… Checks and installs Go 1.21.6 if needed
  • βœ… Installs dependencies (make, git, wget)
  • βœ… Builds the go2ban binary
  • βœ… Installs the systemd service
  • βœ… Opens the configuration file for editing
  • βœ… Optionally starts and enables the service

πŸ’‘ Tip: Run the script as a regular user (not root). It will prompt for sudo password when needed.


πŸ”§ Manual Installation

Prerequisites

Make sure you have Go version >=1.15 installed

# 1. Clone the repository
git clone https://github.com/vv198x/go2ban.git

# 2. Build the binary
make

# 3. Run the installer
sudo make install

# 4. Configure go2ban
vi /etc/go2ban/go2ban.conf

# 5. Start and enable the service
sudo systemctl --now enable go2ban

βš™οΈ Configuration

The config file allows you to customize all aspects of operation:

πŸ”₯ Basic settings

Parameter Description Default
firewall Automatic firewall rule management or disable auto
log_dir Directory for go2ban logs /var/log/go2ban
white_list IP addresses that will never be blocked -
blocked_ips Maximum number of blocked IPs 1000

🌐 API and integrations

Parameter Description Default
grpc_port Port for gRPC communication off
rest_port Port for REST API blocking off

🎣 Traps and protection

Parameter Description Default
trap_ports Trap ports for scanners off
trap_fails Number of attempts before blocking 3
local_service_check_minutes Frequency of service checking 5
local_service_fails Number of failed attempts 5

🌍 AbuseIPDB integration

Parameter Description Default
abuseipdb_apikey API key for AbuseIPDB off
abuseipdb_ips Number of IPs to block from AbuseIPDB 100

πŸ’» Command line

go2ban [options]

Options:
  -cfgFile string
        Path to configuration file
  -clear
        Unblock all IPs
  -d    Run as daemon

🎯 How it works

go2ban runs as a background service, constantly monitoring:

  1. πŸ“Š Service logs β€” databases, web servers, Docker containers
  2. πŸ” Connection attempts to trap ports
  3. 🌐 External threats via AbuseIPDB API
  4. ⚑ Automatic blocking in iptables raw table

πŸš€ Advantages of blocking in raw table

Advantage Description
⚑ Speed Raw table is the first table in the iptables chain, providing instant blocking
πŸ›‘οΈ Security Strong first line of defense against incoming traffic
πŸ’Ύ Resource savings Connections are never established, reducing CPU load

🌟 Impact on the ecosystem

πŸ“ˆ Computational power savings

Thanks to effective blocking of attackers at the raw table level, go2ban helps:

  • Reduce CPU load by up to 70% on attacked servers
  • Save network bandwidth
  • Reduce response time for legitimate users
  • Make the internet faster for everyone

🌍 Security for everyone

Every blocked attacker means:

  • βœ… Fewer attacks on other servers
  • βœ… Reduced overall threat level in the network
  • βœ… More stable operation of internet infrastructure

πŸ› οΈ Development

go2ban is developed in Go using iptables for firewall management. The code is open to the community, and we welcome developer contributions!

πŸ—οΈ Technology stack

  • Go 1.21.6+ β€” main development language
  • iptables/netfilter β€” firewall management
  • systemd β€” system service
  • gRPC/REST β€” API for integration

πŸ“‹ Changelog

For a detailed list of changes in each version, see the change.log file in the repository.


🀝 Support

If you encounter any issues or have questions:

  • πŸ“ Create an Issue
  • πŸ’¬ Contact the developer
  • πŸ“š Study the documentation

πŸ›‘οΈ Protect your server today and help make the internet safer!

⭐ Star on GitHub

About

Protect your servers

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages