Hostxpeed
Login Get Started →
Server Management

How to Whitelist IP in Fail2ban

3 min read
25 views
Jun 10, 2026

Prerequisites

Before whitelisting an IP, make sure you have:

  • Fail2ban installed and running
  • Root or sudo privileges
  • Your current IP address

Step 1: Find Your Current IP

Connect to your VPS:

ssh hxroot@YOUR_SERVER_IP -p 22

Or from any machine:

curl ifconfig.me

Step 2: Add IP to Whitelist

sudo nano /etc/fail2ban/jail.local

Under [DEFAULT] section, add or modify:

[DEFAULT]
ignoreip = 127.0.0.1/8 ::1 YOUR_HOME_IP

Example with multiple IPs:

ignoreip = 127.0.0.1/8 203.0.113.45 192.168.1.0/24

Step 3: Apply Changes

sudo systemctl restart fail2ban

Step 4: Verify Whitelist is Applied

sudo fail2ban-client get sshd ignoreip

Alternative: Whitelist Using fail2ban-client

sudo fail2ban-client set sshd addignoreip 203.0.113.45

This change is temporary and lost after restart. Use jail.local for permanent whitelist.

Whitelist Range (CIDR Notation)

ignoreip = 192.168.1.0/24 10.0.0.0/8

Check Current Whitelist for Specific Jail

sudo fail2ban-client get sshd ignoreip

Remove IP from Whitelist

Edit /etc/fail2ban/jail.local and remove the IP, then restart.

Whitelist Using /etc/hosts.allow (Alternative)

For SSH only, add to /etc/hosts.allow:

sshd: 203.0.113.45

✅ Your IP has been whitelisted. You will not be banned even after multiple failed attempts.

Was this article helpful?