Add a Dedicated IP to a subdomain or addon domain

On this post we will show you how to add a dedicated IP to a subdomain or addon domain without creating any account from WHM.
For this, we will need to edit some cPanel configuration and Apache configuration files. Let’s start.

1. Edit your subdomain or addon domain configuration file:

nano -w /var/cpanel/userdata/usuario/subdomain.domain.com

Content should be similar to this:

customlog:
 -
 format: combined
 target: /usr/local/apache/domlogs/nixcp.com
 -
 format: "\"%{%s}t %I .\\n%{%s}t %O .\""
 target: /usr/local/apache/domlogs/nixcp.com-bytes_log
documentroot: /home/username/public_html
group: Group1
hascgi: 1
homedir: /home/username
ip: 192.168.0.1
owner: username
phpopenbasedirprotect: 1
port: 80
scriptalias:
 -
 path: /home/username/public_html/cgi-bin
 url: /cgi-bin/
 -
 path: /home/username/public_html/cgi-bin/
 url: /cgi-bin/
serveradmin: [email protected]
serveralias: www.nixcp.com
servername: nixcp.com
usecanonicalname: 'Off'
user: username
userdirprotect: ''

2. Edit the IP line and add your new IP, as you see below:

ip: 0.0.0.0

Save the changes now.

3. Rebuild and restart Apache to apply changes:

/usr/local/cpanel/scripts/rebuildhttpdconf
/usr/local/cpanel/scripts/restartsrv_apache

4. Edit the A registry at the DNS records for the subdomain/domain chosen, and add the new IP address. You can do this from WHM > Edit DNS Zone.

5. Finally, mark your IP as reserved from WHM > Show/Edit Reserved IPs

If you need any additional help regarding this, check out the cPanel original documentation from here.

About the Author: Santiago Borges

Experienced Sr. Linux SysAdmin and Web Technologist, passionate about building tools, automating processes, fixing server issues, troubleshooting, securing and optimizing high traffic websites.

Leave a Reply

Your email address will not be published. Required fields are marked *