I recently encountered a problem while adding a new IP address in a VPS system with WHM and Centos 6.4. The problem did not become apparent immediately as WHM does not show any error or warning when I added the new IP address. I record the problem here, as well as the solutions, as a note for the future and for anyone else who might encounter the same problem.
I did the following steps to add the new IP address (which worked without problems previously):
- Logged on to WHM
- Clicked “Add a New IP Address” under “IP Functions”
- I entered the IP address, the subnet mask, and submitted.
I clicked on “Show IP Address Usage” and saw the new IP address and it was free (not assigned to any website). I then clicked on “Change A Site’s IP Address” to assign the new IP to one of the websites in the system. Everything went smoothly without any error. However, the website did not load. I checked that the DNS had propagated, and that when I pinged the domain of the website, it correctly pointed to the new IP address, and yet, the website did not load. I pinged the IP address, and got no replies.
My host gave me a clue to change the subnet mask when I asked for assistance. I then realised what the problem was. But I found no where on WHM that I can change the subnet mask. So I had to log on to the server using SSH. Before I list the solution, I shall explain why the new IP address did not work. Note that the IP Addresses that I used below are not my real IP addresses, just some random IP addresses that I will use for illustration purpose.
My current subnet mask was
255.255.255.248 which would allow a maximum of 6 IP addresses. So my system would have a range of 6 IP addresses that can be used. E.g.
22.214.171.124 - 126.96.36.199. In this case, the Subnet ID would be
188.8.131.52 and the broadcast address would be
184.108.40.206. When I tried to add the new IP address, all the 6 available IP addresses were already used, so I was in fact adding
220.127.116.11 (the broadcast address) as the new IP. Unfortunately WHM did not give any error nor warning, but let me add it successfully, although it would not work.
Having realised the above, I then tried to change the subnet mask to
255.255.255.240, so that I would have 8 more IP addresses that I can use, namely
18.104.22.168 - 22.214.171.124.
I used this Subnet Calculator to help me understand the subnet network calculation.
Below are the steps I took to change the subnet mask
- Log on to the server using SSH
- Update the entries in
The entries in the
/etc/ipslooks like the following
Each line follows the format:
IP Address:Subnet Mask:Broadcast Address
So I adjusted the entries to look like below
Basically, I just changed the subnet mask and broadcast address part.
- Next, go to the following directory:
- Edit the following files:
ifcfg-eth0:1and update the value of NETMASK to
255.255.255.240in those 2 files.
- Restart ipaliases using the command:
- Restart network services using the command:
service network restart
Once I got the subnet mask changed, I went back to WHM to add the new IP address again with the new subnet mask, and then assigned it to the website and it worked perfectly.