Setting up Amazon EC2 is quick and easy, you can build a server within less than an hour.
I initially used a great guide posted by Rob Scott which shows how to setup a VPC with security group, an EC2 instance and then how to install WHM on it. I used the guide as reference to my own way of doing it though and it gave me the foundation I needed, especially being unfamiliar with AWS.
The guide tells you how to use Route53 for the DNS which I didn’t follow. I wanted to setup my own, private nameservers. The main reasons were aesthetic (the looks of it in WHOIS) and also so that I could point all my domains to the same two nameservers and never have to change them. If an IP ever had to be swapped out, I could just change the IP at the registrar but the nameservers would remain the same.
I assume that you’ve followed the guide to the point where you have a running Amazon EC2 instance, one network interface with one private IP and an elastic IP associated to that which is public and that you have then installed WHM. If you haven’t started the WHM install yet, that is okay, you can do the IP configuration during the installation of WHM.
So follow these steps to setup private nameservers on Amazon EC2 running WHM:
1. Manage private and elastic IPs
In the guide as mentioned above, Rob showed you how to create one, primary IP address which is private. He then also showed you to create an elastic IP and associate it with that private IP address you created. We want to create another private and public/elastic IP. One for each nameserver.
Now go to your AWS console and go to EC2. Then click “Instances” where you’ll see all your instances. Select the specific instance and click “Actions” at the top or right-click on the instance name. Then select “Manage Private IP Addresses“. Click “Assign New IP” and leave the box on “Auto Assign” and make sure you tick/check the “Allow reassociation” checkbox and then update. It created 10.0.0.172 for me.
Now go to Network & Security > Elastic IPs in your EC2 dashboard. Click the “Allocate New Address” button at the top to create an IP address. Once it has been created, select the elastic IP and click “Associate Address” at the top or right-click on it and select “Associate Address“. A dialog will appear.
Leave the instance empty and under network interface, click inside the field to load the network interfaces. Now choose the same network interface that you created the primary, private IP address on. Then under “Private IP Address“, select the private IP that we just created in the previous step and then tick/check the “Reassociation” checkbox and click “Associate” to finish.
That’s it for this step. You now have two private IPs on the network interface of the instance and you have two public, elastic IPs, each associated to one of the private IP addresses.
2. WHM IP Address Setup
If you haven’t installed WHM yet, you can do that now and it will allow you to add IP addresses during the setup process after installation.
If you have already installed WHM, you can go to IP Functions > Add New IP Address in WHM.
For both, remember that by default, it will be in NAT mode so you’ll enter the private IP addresses into WHM and not the elastic IPs. WHM will automatically route the private IP addresses to their associated elastic IPs for you, don’t worry about that.
In this case, the private IP that we just created was 10.0.0.172. So I’ll enter that into the box and submit it. Do the same for your other private IP address that you created on the instance earlier on in Rob’s guide accordingly. Again, do not enter the elastic IP, it will not work, it will just be unroutable unless you are not in NAT mode.
That’s it for the WHM setup. WHM will automatically route the private IP addresses to the elastic IPs and do the work for you.
3. Register Nameservers at Registrar
Now we need to register the private nameservers for our IP addresses at the registrar where the domain is registered or you could use a 3rd party DNS service if you wanted to but in this case I wanted the nameservers to be ns1.domain.com and ns2.domain.com where domain.com is my domain.
If you don’t have a domain that you want to use for the nameservers, you can just go and register one right now.
Login to your account at your registar like GoDaddy or Dynadot for example. Each registrar will give you documentation or help on registering private nameservers/hostnames so I’m not going to post different registrars here but I’ll give you the instructions for GoDaddy and Dynadot. Both are equally easy to do but GoDaddy seems very slow to propagate DNS compared to Dynadot from my experience. That is also why I have moved most of my domains over.
Once you are logged into your GoDaddy account, click the “Launch” button next to “Domains“. Then you’ll be shown a list of domains where you’ll click the name of the domain that you’ll be using for the private nameservers.
On the domain details page, scroll down inside the “Settings” tab until you see “Host Names“. Then click “Manage” link which will open a dialog where you will click “Add Hostname“. Fill in the name of the nameservers that you want, eg. ns1.domain.com and then the one elastic IP that you associated to the instance through the network device earlier on. Then do the same for the second nameserver eg. ns2.domain.com and the other elastic IP you associated to the other private IP address.
Go to Domains, then you’ll see a list of all your domains.
For the specific domain that you want to use for the two nameservers, click on the link in the “Name Server” column of the table. It will take you to a page where you will see several choices such as name servers, parking, forwarding, etc. Select the “Name Servers” tab and directly under that click the “manage name servers” link. Then on the next page just click the “Register a domain name server” link.
So you will be presented with a form. First fill in the nameserver you wish to have eg. ns1.domain.com and then in the next field, fill in your one elastic IP address that you previously associated with your instance through the network interface. Then submit and do the same thing a second time using another nameserver eg. ns2.domain.com and the other elastic IP you associated to the other private IP address on the instance.
4. Test Nameservers
WHM will automatically update itself with your new nameservers after several hours as the DNS has propagated. You can go to DNS Functions > NS Record Report in WHM to see the nameservers and their public IP addresses. If they do not appear immediately, do not be alarmed, they will show up if you followed the steps correctly. It needs to propagate.
Now you can go to your registrar and point a domain to your two nameservers and wait for it to propagate. In Dynadot for example, since you have registered two private nameservers, they will automatically appear in the drop down menu showing the list of available nameservers to choose from.
Enjoy and good luck and feel free to comment here if you have any questions.