Adding IP Addresses to a Server

4/5 - (4 votes)

In a hosted multi-site environment you may find yourself needing to add multiple IP addresses to a server. Luckily, cPanel makes it very easy to add IP addresses. This article will go over adding IP addresses to standalone servers, both through WHM and from command line on a cPanel server.

 

You probably already know why you need more IPs on your server if you’re reading this, but humor me for a second. Here are a few reasons why you might need to add some more IPs:

 

*You are hosting multiple accounts/sites, some of which utilize SSL certificates. Apache requires each SSL certificate to have its own IP, and cPanel (currently) limits each account to one IP address…

*…So, you need to be able to assign sites to different IP addresses. Or  you host one of the idiots out there that thinks having each site on a separate IP is actually going to up their search engine rankings.

*You need more IP addresses to send email from, because your mail server’s IP is blacklisted

*You need to resolve routing or bandwidth problems between your server and other networks

 

cPanel utilizes the ipaliases service to process additional IP’s as virtual interfaces. Those of you already familiar with Linux IP aliasing using the ifcfg command probably already know that you can add an IP alias to, say, eth0, with the following command:

ifconfig eth0:0 123.456.789.123  netmask 255.255.255.0 up

 

While this would technically work, it’s not how cPanel wants you to do it. When it comes to safely adding IPs to a standalone server, you have two options:

*Add the IP in WHM

*Add the IP directly to the ipaliases configuration

 

Understanding the Process

 

When you add an IP to a cPanel server using a supported method, cPanel performs the following process:

1)Adds the IP as a alias to the main interface (usually eth0)

2)Rebuilds the IP Address pool (/scripts/rebuildippool ~> /etc/ipaddrpool)

 

The WHM Method

 

To add an IP address via WHM, you can simply log in as a root user and go to “Add a New IP Address”, enter the IP and its subnet mask, and hit “Submit.”

 

The Command Line Method

 

You can also add IPs via command line in a way that cPanel understands, which is mainly useful when doing automated server setups, or adding multiple IPs across multiple servers. To do this, you’d edit the ipaliases load file, which is /etc/ips . If you already have additional IP addresses on your server added as aliases you may already see how this file is formatted, but here’s an example:

123.456.789.123:255.255.255.0:123.456.789.255

 

This is a colon-delimited file with each IP address on its own line. The first field is the IP itself, the second is its subnet mask, and the third is its broadcast. You can add as many IPs as you need, putting each on its own line.  When you’re done, run the following commands:

service ipaliases reload (or service ipaliases restart)

/scripts/rebuildippool

 

To check whether the IPs have been added successfully, you can perform any of the following tests:

/scripts/ipusage  <~ will show the IP usage of the server

ifconfig <~ will show all IPs on the server

ping $ip <~ will ping the IP ($ip) you added to make sure it’s routing

 

Note that for many VPS/Virtualized platforms (like Virtuozzo, OpenVZ, etc), you have to add the IP through the parent node in order for it to work. For OpenVZ/Virtuozzo, you would do:

vzctl set $VEID –ipadd 123.456.678.123 –save  (pass –ipdel to remove an IP)

 

Then enter into the VPS and run /scripts/rebuildippool . In some cases you may also need to refresh the cPanel license:

/usr/local/cpanel/cpkeyclt

 

Removing an IP Address

 

Removing IP is exactly the opposite, where you can remove the IP from WHM ~> “Show or Delete Current IP Addresses” or by removing the IP lines from /etc/ips and reloading ipaliases.

 

Once you’ve added and assigned an IP to the server, cPanel will not let you remove it unless you change the IP address of the account using it to something else. If you want to override this, you can manually add the IP to /etc/ipaddrpool  and safely remove the IP via WHM. However, this in some cases has been known to unroute the other IPs on the server, so you’ll likely need to reload ipaliases again.

zp8497586rq

2 Comments

Log in