You have ordered new IP addresses, then chose the server at the same location, yet you still cannot ping it? That is because the IP is not configured on your server's network interface yet. There are various ways to do that, some are better than others, thus we will show you a simplest approach.
In this example we will use subnet of
22.214.171.124/32 which is assigned to a Cloud Server TestServer2 server at Frankfurt using CentOS 7 v2.0.4.
Note: do not forget to stop and then start the Cloud Server after assigning the additional IPs to the server (thank you, our clients, for pointing this out!).
Firstly, to configure the IP, you have to connect to the server, for that you will need the connection details: main IP, user and password or SSH key, depending on the way your server is configured. To get this info, go to Terminal > Cloud Hosting > Cloud Servers, then select the server.
To connect to the server we will use PuTTY.
Copy the password before actually logging to the server, then type root for user, for password just press the right mouse button and press enter (the password will be pasted automatically).
Let's check the current configurations of network interfaces, to do that type
ip a .
Furthermore, we need the name of our network interface. In the picture above we can see that it is eth0 and that our main IP is already configured. Now we can add our secondary IP to the interface as alias. We can check that secondary IP is not configured or used by pinging it.
To add the IP as an interface alias, we will use this command:
ip addr add 126.96.36.199/32 dev eth0:0
For IPv6 add -6, for example:
ip -6 addr add fdxx:xxxx:xxxx:yyyy:zzzz:zzzz:zzzz:zzzz dev eth0:0
After this, we can check whether it is pinging:
We can also inspect the network interface on the server using
ip a command again:
However, there is a downside to this approach - after restart of this server, this configuration is dropped.
On the other hand, we can easily overcome this problem using rc.local script, which is traditionally executed after all the normal system services have started. To edit it, you can use any available editor, in this example, we will use NANO editor. If you do not have it, you can easily install nano with command
sudo apt-get install nano for Debian and Ubuntu systems, or use
yum install nano for CentOS systems.
Now, go to /etc using command
cd /etc , then type
nano rc.local . Paste the commands you want to keep after restart to the file (remember, you can paste in PuTTY by pressing right mouse button) and save it using shortcut CTRL+X. After that, make sure to remember to type
chmod +x /etc/rc.d/rc.local and
chmod +x /etc/rc.local so that your script is executable.
The next step is not necessary, but you can check whether your configurations are saved after restart. To do that, just type
sudo reboot , reconnect to the server, then again use
ip a to inspect the configuration.
If your configuration is not saved, most frequently users omit the step of making the script executable, thus make sure not to forget that.
Another problem you might face using this approach is that there is no rc.local script - some new distributions have it disabled. You can find information about enabling it here.
What is important to mention, that all IP addresses routed to your server have the same gateway. There is no difference how you configure additional IP addresses but all of them will have the same gateway. By default all additional IP ranges are being routed statically to the server main IP address. Gateway can be found by going to your servers overview page, Network tab or just type 'ip r' when you are inside your server.
Approach 2: Configure full IP range
Moreover, this can be done using IP range approach adding the IP range configuration in a script that would automatically configure the IP range once the network is restarted. For this operation we need to know the name of the interface (in this example we will use
eth0). Furthermore, the additional IP has to be assigned to the server via Terminal and the server should be stopped/started before assigning the IPs.
Let's go to
Then create a new file:
Note that the
eth0 is the network interface name and
range0 is the number of the range to add (next file would be
ifcfg-eth0-range1 and etc).
Let's fill the file with the configuration (the range we are trying to add is 188.8.131.52/29 and for gateway we will use the gateway for the main IP of the server).
To find the gateway of the main IP of the server, simply go to Terminal, select your server, click on
Now let's fill the file with configuration:
And do not forget to restart the network service.
systemctl restart network
Now let us inspect the configuration:
Let's check the connection:
Perfect, the range is now configured on the network interface.