Delete an IP address via SSH from your cPanel server

How to delete an IP address via SSH

Normally, you delete an IP address by logging into WHM and removing the it using the function “Show or delete current IP address” under “IP functions” .

Alternatively you can remove the IP in SSH via linux command.

nano /etc/ips

and now remove the line of the IP and then restart the ipaliases service by the command

service ipaliases restart
/scripts/rebuildippool

You can recheck if the IP has gone by using the command

ifconfig

To delete an IP address via SSH in Linux, follow these steps:

  1. Connect to your server via SSH using your terminal application.
  2. Type the following command to view the list of IP addresses currently assigned to your server:
    ip addr show
    

    This will display the list of IP addresses assigned to your server along with their associated network interfaces.

  3. Identify the IP address you want to delete and note the name of its network interface.
  4. Type the following command to delete the IP address:
    sudo ip addr del [ip_address]/[subnet_mask] dev [network_interface_name]
    

    Replace [ip_address]/[subnet_mask] with the IP address and subnet mask you want to delete (e.g., 192.168.1.100/24) and [network_interface_name] with the name of the network interface associated with the IP address (e.g., eth0).

    For example, if you want to delete the IP address 192.168.1.100/24 on the eth0 network interface, you would use the following command:

    sudo ip addr del 192.168.1.100/24 dev eth0
    
  5. Verify that the IP address has been deleted by typing the following command:
    ip addr show
    

    This will display the updated list of IP addresses assigned to your server. The IP address you deleted should no longer appear in the list.

Step by step : Delete an IP address via SSH from your cPanel server

If you want to remove (unblock) an IP address that has been blocked (usually due to multiple failed login attempts) on a cPanel server, you’d typically interact with the server’s firewall. Common firewalls used with cPanel are ConfigServer Security & Firewall (CSF) and cPHulk.

Here are the steps for both:

1. Using CSF (ConfigServer Security & Firewall):

If you have CSF installed, you can use it to unblock an IP.

Check if an IP is blocked:

bash
csf -g [IP_ADDRESS]

Unblock the IP:

bash
csf -dr [IP_ADDRESS]

If you want to add an IP address to the allow list permanently, so it doesn’t get blocked:

bash
csf -a [IP_ADDRESS]

Finally, restart CSF to apply the changes:

bash
csf -r

2. Using cPHulk (cPanel’s built-in brute force protection):

To check blocked IPs:

Log in to WHM and navigate to cPHulk Brute Force Protection. You can view the list of blocked IPs there.

To unblock an IP via SSH:

If you have root access and are comfortable using the command line, you can interact with the cPHulk database directly. Here’s a basic example:

First, access the MySQL database:

bash
mysql

Then, select the cPHulk database and delete the IP:

sql
USE cphulkd;
DELETE FROM brutes WHERE IP="IP_ADDRESS";

Replace "IP_ADDRESS" with the actual IP address you want to unblock.

Exit MySQL:

sql
EXIT;

NOTE: These operations require root access to the server. Also, always be careful when interacting directly with databases, as it’s possible to inadvertently make undesirable changes or deletions.

In any case, if you’re not sure why an IP is being blocked, it’s essential to investigate further to ensure you’re not removing a legitimate threat. Always make sure to monitor server logs and stay informed about the activity on your server.

Previous Post
Using the iPhone WordPress App
Next Post
Essential tools to troubleshoot DNS issues

Get Online Today!

  

Your perfect domain name is waiting!

Search our huge portfolio for more domain name extensions and pricing below
domain name extensions

Classic Domain Names

.COM | .AU | .CO | .NET | .BIZ | .ME | .EU | .ASIA | .TV | .MOBI | .NAME | .INFO | .ORG | .US | .NL| .FM | .HK | .ES | .CO.NZ | .DE | .CO.UK | .RU | .IM | .PM | .TW | .FR | .CN | .CA | .CH | .VN | .PL | .IL | .JP | .KR |