How To Configure WHM Custom Nameservers With Cloudflare And Namecheap

Joseph Matino
How To Configure Whm Custom Nameservers With Cloudflare And Namecheap

Configuring WHM with custom nameservers can be tricky when you need to keep your primary domain’s settings the same. Here, I’ll show how I did this using example.com as our example.

example.com, registered with Namecheap, uses Cloudflare’s nameservers to boost its security and performance. To change my server settings without affecting this setup, I created a new hostname, whm.example.com, for WHM and cPanel operations.

This allowed example.com to keep its benefits from Cloudflare without any interruptions.

My method was to set up whm.example.com with its own custom nameservers, connecting them back to example.com as glue records. This setup let me manage server settings on my own while keeping the main domain stable and fast.

I’ll walk you through the steps I took to put this configuration in place, making sure that your domain stays secure and runs smoothly.

Considerations Before Setting up WHM Nameservers

Before Setting up WHM nameservers for your subdomain, ensure you follow these steps to prepare properly:

1. Check Server Security Settings

How To Configure Whm Custom Nameservers With Cloudflare And Namecheap

Ensure your server’s security settings are correctly configured to avoid potential issues. You can check these settings through your hosting provider’s dashboard or contact their support team for help.

2. Verify DNS Ports are Open

WHM and cPanel require specific DNS ports to be open to function properly. These include:

  • TCP port 53: This port handles DNS queries that require guaranteed delivery. TCP is used for tasks where accuracy is more important than speed, ensuring that data packets are sent and received in the order they were sent.
  • UDP port 53: This port deals with the majority of DNS queries and is used where speed is preferable over reliability. UDP does not guarantee the order of packets, making it faster but less reliable than TCP.

Commands to verify if these ports are open:

For Ubuntu:

netstat -plntu | grep :53

For AlmaLinux/CentOS:

netstat -plntu | grep :53

Or

ss -plntu | grep :53

3. Register and Configure Your Subdomain

Ensure your subdomain, such as whm-clients.example.com, is registered and configured correctly in your domain’s DNS settings. Proper configuration is crucial for keeping everything running smoothly.

4. Update Your System

Regularly update your system with the latest security patches to minimize the risk of vulnerabilities that could affect your setup.

Step 1: Set Up Your Dedicated WHM Hostname

When setting up WHM with custom nameservers, the first step is to create a dedicated hostname. This hostname acts as the foundation for your server and nameserver configuration. For our example, we’ll use “whm.example.com”.

Log into your WHM:

Start by accessing your WebHost Manager (WHM) dashboard. You typically do this by entering the URL in your browser’s address bar, which looks like https://your-server-ip:2087 or https://your-domain.com/whm.

Navigate to ‘Basic WebHost Manager® Setup’

Once inside WHM, look for the ‘Basic WebHost Manager® Setup’ under the ‘Server Configuration’ section. Click on it to proceed.

Set the Hostname:

How To Configure Whm Custom Nameservers With Cloudflare And Namecheap

In the ‘Basic Config’ section, you’ll find an option to enter or change the hostname. Make sure your hostname follows the format whm.example.com. This format is crucial as it separates the management of your WHM from the primary domain activities on example.com.

Save Changes:

After entering the new hostname, save your changes. WHM may require a few moments to update the settings across the system.

By setting up a dedicated hostname like whm.example.com, you ensure that any configurations related to WHM and cPanel do not interfere with the operations of your primary domain, example.com. This separation is important for maintaining the stability and security of both domains.

Step 2: Add A and NS Records in Cloudflare for WHM

Setting up your WHM hostname involves more than just an A record. You also need to establish NS records to use custom nameservers like ns1.example.com and ns2.example.com.

Log in to Cloudflare:

Access your account by visiting their website and logging in. Select example.com from your list of domains.

Go to DNS settings: Click the ‘DNS’ tab in your dashboard to manage DNS records.

Add the A record:

  • Record Type: A
  • Name: whm (This creates whm.example.com)
  • IPv4 address: Input the IP address of your WHM server, e.g., 123.456.789.0.

Add the NS records:

  • If you are using names like ns1.example.com, you need to create NS records that point to your WHM server but using the base domain example.com.
    • Record Type: NS
    • Name: ns1 (This will be fully qualified as ns1.example.com)
    • Value: whm.example.com
    • Do the same for ns2.example.com, pointing it to whm.example.com.

Set TTL:

Choose a TTL (Time to Live) for your records. A shorter TTL can help with quicker updates, which is beneficial during the setup process.

Save changes:

After entering all details, click ‘Save’ to implement your DNS updates. DNS changes might take a while to propagate, often anywhere from a few minutes to 48 hours.

By setting up both A and NS records in Cloudflare, you link your WHM server to your domain and designate your own subdomains (ns1.example.com and ns2.example.com) as nameservers. This setup is crucial for managing DNS resolutions internally without affecting the primary operations of example.com.

Step 3: Set Up Custom Nameservers in WHM

After you set up the A records and nameservers on Cloudflare, the next step is to configure these nameservers in WHM. This part links the nameservers to the same IP addresses used in Cloudflare and makes sure they are ready to handle DNS requests for your domain.

How to configure your custom nameservers in WHM:

Log into WHM and go to ‘Server Configuration’, then ‘Basic WebHost Manager® Setup’. Here you can adjust your server’s basic settings.

How To Configure Whm Custom Nameservers With Cloudflare And Namecheap

Enter Nameserver Details

At the bottom of the Basic WebHost Manager® Setup page, there’s a section for nameservers. Type in your custom nameserver details such as ns1.example.com and ns2.example.com.

Link Nameservers to IP Addresses

Make sure each nameserver is connected to the correct IP addresses, the same ones you set for the A records in Cloudflare. If you added AAAA records in Cloudflare and your server uses IPv6, add them here too.

Update DNS Settings

Go to ‘DNS Functions’, then ‘Edit DNS Zone’ and pick your domain, example.com. Check that you have A records for ns1.example.com and ns2.example.com pointing to the right IP addresses. If you are using IPv6, add AAAA records. Also, add NS records to set these nameservers as authoritative.

Confirm Changes

Double-check all details for accuracy and save your changes. Remember, DNS updates might take a while to take effect, so give it some time.

This setup ensures that your custom nameservers work correctly in WHM, matching the configurations you made in Cloudflare, and help manage your domain’s DNS effectively.

Step 4: Create Glue Records in Namecheap for WHM

Once your nameservers in WHM are linked to their IP addresses, you need to register these as glue records with Namecheap for your domain example.com.

It’s important to note that glue records can only be set up under the domain they are meant to serve. This means if you’re setting up ns1.example.com and ns2.example.com as nameservers, these glue records must be registered specifically under example.com.

Log into Namecheap

Sign into your Namecheap account and head to the dashboard to manage your domains.

Access Domain Management

In the dashboard, select ‘Domain List’ from the left menu. Find example.com and click on ‘Manage‘ to open the settings for this domain.

Find the Advanced DNS Settings

In the domain management section, locate the ‘Advanced DNS’ section where you handle DNS configurations that are more complex.

Create Glue Records

How To Configure Whm Custom Nameservers With Cloudflare And Namecheap

Look for the option to add or register nameservers. Here, add ns1.example.com and ns2.example.com. Make sure to associate each with the IP addresses you’ve set in Cloudflare and WHM. This setup is critical because it ensures that example.com can effectively use these nameservers to direct DNS queries.

Glue records are essential for preventing DNS resolution issues and must be registered under the domain they will serve. By setting these up under example.com, they become functional for any subdomains or client domains that wish to use example.com‘s custom nameservers like ns1.example.com and ns2.example.com.

Verify and Save Changes

Check all the details to ensure they are correct and save your changes. This updates the DNS configurations for your domain, ensuring efficient routing of traffic through your custom nameservers.

This step solidifies your domain’s DNS management, making it more robust and reliable for handling internet traffic, and allows other clients to use these nameservers effectively.

Finally: Verify Nameserver Functionality

Finally, we’ve reached the last step in setting up custom nameservers with Cloudflare and Namecheap for your WHM. I hope this guide has been clear and helpful so far. Now, let’s ensure everything is configured correctly.

Please remember that ‘example.com’ and ‘whm.example.com’ are used here as examples. Be sure to replace them with your actual domain names when performing these checks.

Start with an easy and quick verification using an online tool like DNS Checker. Enter your actual domain name in the search field, select ‘NS’ for nameservers, and hit search to see if your nameservers are propagating correctly across the internet.

For a more in-depth check, you can use terminal commands. To verify the NS records for your WHM hostname, run the following command:

dig @ns1.yourdomain.com whm.yourdomain.com NS +short

This queries your custom nameserver to ensure it’s returning the right information. Similarly, to check the A record for ‘ns1.yourdomain.com’, you can use:

dig ns1.yourdomain.com A +short

This should return the IP address associated with your nameserver. Lastly, to get a comprehensive overview of all DNS records associated with your WHM hostname, the command would be:

dig whm.yourdomain.com ANY +short

If the information returned from these commands matches your configuration, then everything is set up correctly. If the commands show no output or incorrect details, it might be due to DNS changes still propagating, which can take up to 48 hours. Make sure also to check that all necessary DNS ports are open.

If you found this guide helpful or if you encounter any issues, don’t hesitate to comment below.

Share This Article
Leave a comment