There might be a situation where you want to change IP address of account on cPanel server without actually using WHM/cPanel. Its possible WHM API is also not available and you just need to do this manually from command prompt.
Many a times server is not cpanel licensed yet and things need to be setup before server is licensed for live site.
This custom script can be helpful in this scenario which can be used to simply change IP address of cpanel account.
Please follow these steps
- Login to server as root user using your favourate SSH client, these steps are valid for Almalinux and Ubuntu based OS
cd /usr/local/src
[root@divalinux src]#
- Create empty file using vi or nano command
nano ipchange.sh
or
vi ipchange.sh
- Add this code in new .sh file and save it
#!
# https://divalinux.com
#Change IP address Script
IP=192.168.1.1
for USER in `cat /etc/trueuserdomains | cut -d: -f2` ;
do /usr/local/cpanel/bin/setsiteip -u $USER $IP ;
done
Change IP field from 192.168.1.1 to your server IP which you want to setup as new IP address
- Save the file and change permission of file to 755
chmod 755 ipchange.sh
- Now simply run the script to see the magic happen
./ipchange.sh
Script will go through the motions and change IP address of all cPanel accounts on server to new IP address. It will also give status and notify of the IP change.