Changing Subnet Mask in Centos 6.4 VPS System

By | 24 September 2013

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.
  • Success!

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 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. - In this case, the Subnet ID would be and the broadcast address would be When I tried to add the new IP address, all the 6 available IP addresses were already used, so I was in fact adding (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, so that I would have 8 more IP addresses that I can use, namely -

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 /etc/ips
    The entries in the /etc/ips looks 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: etc/sysconfig/network-scripts/
  • Edit the following files: ifcfg-eth0 and ifcfg-eth0:1 and update the value of NETMASK to in those 2 files.
  • Restart ipaliases using the command: /etc/rc.d/init.d/ipaliases restart
  • 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.