How to add an IP to a WHM/cPanel server via SSH

Prev Next

Sometimes it's quicker to administer a server via SSH, rather than logging into the WHM control panel and using the Graphical User Interface. The whmapi1 command-line tool is very useful for performing certain WHM administration tasks via SSH.

The following whmapi1 commands work on any WHM/cPanel server, no matter what distribution it's running.

To demonstrate, adding an IP address 221.121.xxx.xxx with a subnet mask of 255.255.255.0 to your server utilising whmapi1 would be as follows:

  1. Connect to your server via SSH to begin using the details you have been provided:

ssh -p 22 root@your.server.ip.address

  1. Enter the following ‘whmapi1‘ command to add an IP address and subnet.

whmapi1 addips ips=221.121.xxx.xxx netmask=255.255.255.0

  1. Make sure the new IP address is reachable by pinging it outside of your active SSH session.

ping 221.121.xxx.xxx

  1. Once the new IP address is added and verified as working, you can assign the IP to a cPanel account. You can also assign the IP to multiple accounts.

whmapi1 setsiteip ip=221.121.xxx.xxx user=cpanel_username

  1. If needed, you can check which IP address an account is currently in use:

whmapi1 accountsummary user=cpanelusername

To list all IP addresses configured on the server for each user

whmapi1 listaccts | grep -E 'user|ip:'

You can also remove the IP address with the following command:

whmapi1 delip ip=221.121.xxx.xxx

To confirm that the IP has been removed

whmapi1 listips

If you have any issues with the above process, please feel free to submit a support ticket for further assistance.