Add or Remove Ip address via Shell on cPanel/WHM server

QUESTIONS CENTRECategory: apacheAdd or Remove Ip address via Shell on cPanel/WHM server
ZENHOST Support Staff asked 3 years ago

Its quite easy to add or remove ip address on a cPanel/WHM server using the GUI interface.

If you face any difficulty to add via GUI, you can follow the steps listed below to add it via shell.

To add an ip address on your CentOS server without any control panel, refer the following URL.

Steps to Add secondary ip address on CentOS Server

To add an IP address you need to open the file /etc/ips and enter the IP address, subnet mask & broadcast ip separated by columns. Sample entry will look like below.

192.168.1.1:255.255.255.0:192.168.1.2

Save and quit.

 

Now restart ipaliases.

service ipaliases restart

 

Rebuild the ip address pool.

/scripts/rebuildippool

Done.

Steps to Remove secondary ip address on CentOS Server

To remove an ip address, you need to stop the ipaliases first.

service ipaliases stop
Open the /etc/ips

vi /etc/ips
Delete the required ip address along with the line from the above file.

service ipaliases start
Start ipaliases and rebuild the pool.

/scripts/rebuildippool
Thats it.

 

 

If you wish to assign an ip address to a particular user/website, you can use the following command.

/usr/local/cpanel/bin/setsiteip -u $username $ip