How to Assign an IP To Multiple cPanel Accounts

How to Assign an IP To Multiple cPanel Accounts
Cpanel 11.25 introduces a new feature to allow you to set a reseller’s shared IP to be different
from that of the server’s shared IP. This feature can be activated in WHM > Reseller Center >
Manage reseller’s shared/main IP. While this will allow you to have multiple accounts on the
same IP, those accounts have to be owned by the reseller and will all be using the same IP.
What if you have a dedicated IP that you want a couple accounts to share? There’s currently no
built-in cPanel functionality to do this, but you can alter a couple files to make it happen.
This walkthrough is for changing the IP of a domain/account to one that is already taken by
another account. If you’re simply changing the site’s IP to one that is free, use the WHM >
Change Site’s IP Address function instead.
Change the DNS
You can edit the DNS zone in WHM > Edit DNS Zone, or edit /var/named/yourdomain.com.db
directly to point the domain to the desired IP on the server. Make sure to increment the serial
number, then run /scripts/dnscluster synczone yourdomain.com to sync it up to your
nameservers. If you’re using external DNS, you’ll obviously need to point the domain in those
nameservers instead.
Edit the cPanel Files
You need to change instances of the old IP to the new IP in the following locations, replacing
$user with the username of the account, and $domain with the domain you are changing the IP
for.
/var/cpanel/users/$user
/var/cpanel/userdata/$user/$domain
Now, add the IP to /etc/domainips in the same format as the others:
xxx.xxx.xxx.xxx: $domain
Build the Configs
Now rebuild the Apache config:
/scripts/rebuildhttpdconf
service httpd restart
That site should now be using the IP you specified. Keep in mind that if your ISP is caching the
old IP, your default server page will show up instead of your website, until the IP change is
propagated. This can take 4-24 hours.