Assigning a Dedicated IP Address to a Subdomain using WHM

This article provides steps for assigning a dedicated IP address to a subdomain using WHM. This guide is intended for users of cPanel VPS and cPanel dedicated servers and will require access to a root-equivalent user.

Launch 100% SSD VPS from $3.19/mo!

Assigning a Dedicated IP Address to a Subdomain using WHM

To assign a dedicated IP address to a subdomain, perform the following steps:

  1. Add the dedicated IP address to the user's subdomain file.

    Note:

    In this example, subdomain.example.com represents the subdomain to which to assign a dedicated IP address.

    To add the dedicated IP address to the subdomain.example.com file, perform the following steps:

    1. Log in to the server as the root user via SSH.

    2. Navigate to the /var/cpanel/userdata/username directory.

      Note:

      username represents the user who requires that each subdomain use a dedicated IP address.

    3. Open the subdomain.example.com file with a text editor. The file's contents will resemble the following example:

      customlog:
        -
          format: combined
          target: /usr/local/apache/domlogs/example.com
        -
          format: "\"%{%s}t %I .\\n%{%s}t %O .\""
          target: /usr/local/apache/domlogs/example.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: webmaster@example.com
      serveralias: www.example.com
      servername: example.com
      usecanonicalname: 'Off'
      user: username
      userdirprotect: ''
    4. Change the ip line to reflect the dedicated IP address to assign to the subdomain, for example:

      ip: 192.168.0.20

      Important:

      On servers that use the 1:1 NAT configuration, you must add the server's internal IP address to this file.

  2. Rebuild and restart Apache

    After you modify the appropriate files, rebuild and restart Apache. To do this, perform either of the following actions:

    • Manually rebuild and restart Apache. To do this, run the following commands:

      /usr/local/cpanel/scripts/rebuildhttpdconf
      /usr/local/cpanel/scripts/restartsrv_apache
    • Rebuild and restart Apache in WHM's Restart Services interface (Home >> Services >> Restart Services)

  3. Add the IP address to the nameserver records

    Add the subdomain's dedicated IP address to the server's nameserver records. To do this, use either of the following methods:

    • Edit the subdomain's IP address in WHM's Edit DNS Zone interface (Home >> DNS Functions >> Edit DNS Zone).

    • Edit the subdomain's IP address with the WHM API 1 Functions - editzonerecord function call.

  4. Reserve the dedicated IP address

    To reserve the subdomain's dedicated IP address, Add the subdomains' dedicated IP address to the reserved IP list so that the system does not assign it other accounts or sites. Perform this action in WHM's Show/Edit Reserved IPs interface (Home >> IP Functions >> Show/Edit Reserved IPs).

Launch 100% SSD VPS from $3.19/mo!

Conclusion

You now know the process for assigning a dedicated IP address to a subdomain using WHM.

  • whm, cpanel, reseller guides, cpanel cloud, cpanel vps, subdomain, domains, ip address, dedicated ip, dedicated hosting, a record, apache, virtualhost, nameservers, dns records, dns, dns zone editor
  • 361 Users Found This Useful
Was this answer helpful?

Related Articles

Disable Network Manager on CentOS 7

This article will provide the steps to disable Network Manager in CentOS 7. Network Manager is...

Disable Network Manager on CentOS 6

This article will provide the steps to disable Network Manager in CentOS 6. Network Manager is...

How to Find the IP of cPanel/WHM Server

This tutorial is designed to troubleshoot and diagnose issues with cPanel license errors. Find...

Uninstall WHMXtra on cPanel Server

This article provides a quick and direct guide for uninstalling the WHMXtra plugin from a...

How to Customize cPanel Installation

This article provides a guide for customizing a cPanel server installation, using the...