When you have bought a server with a main IP and assigned additional IPs, additional IPs are routed statically on your main IPs, thus no gateway or broadcast addresses are needed when configuring the IPs on your NIC.

However, when using additional IPs, the default route of the server is still via gateway of your primary IP. How to reroute all the traffic via additional IP?

To begin with, in this example we will use Kronos Cloud server with CentOS 7 OS, with main IP 185.142.27.190. For additional IP we will use 141.98.89.0/32 which we have already assigned to our server via Terminal. 

Note: after assigning the additional IPs to the server, do not forget to perform stop/start of the server for the routing to be fully finished, or else you might not see the desired results.

Changing the default route is not that hard, it might be done temporarily, or permanently. 

Temporary solution:

Let's check the network configuration:

ip a

Inspect the results:

Now, let's add the additional IP:

ip addr add 141.98.89.0/32 dev eth0

Check the network configuration again:

We see the IP address was added successfully. 

Checking from some other computer/server, we can see it gives ping replies

Now, let's check the default route:

ip r

Let's change the default route for the source IP:

ip r change default via 185.142.27.1 src 141.98.89.0

Inspect the results:

This is it! The traffic is now rerouted to go via additional IP.  

Note: after performing network service restart or restarting the server - these changes will be reverted back to defaults.

Permanent solution:

A permanent solution is as easy as the temporary one:
Let's edit the /etc/sysconfig/networking-scripts/ifcfg-eth0 file (if your network interface name is eth0):

vi /etc/sysconfig/networking-scripts/ifcfg-eth0

Note: as our examples if for Kronos Cloud server, we need to configure the IP address statically.

Here is how our configuration looks in this example case:

Make sure there are no mistakes in this file, we suggest you firstly configuring static IP, then restarting network service, then configuring second IP in the same file and only the adding the SRCADDR (source address) or else you might lose connection to your server (in this case, use the virtual console via Heficed Terminal to reach your server).

Check the results:

ip r

And that is exactly what we were aiming for. 

Did this answer your question?