Adding a Public IPv4 Address to a Linux Server (Ubuntu)

To configure an additional public IPv4 address in Ubuntu, proceed as follows:

Prerequisites:

In the Cloud Panel you have assigned an additional public IPv4 address to your server.

You have logged in to the server.

Step 1

To configure the main IP address as static, you must change in /etc/network/interfaces the entry for eth0. To carry out this change, enter the following:

vi /etc/network/interfaces
auto eth0
iface eth0 inet static
address ABC.DEF.GHI.JKL
netmask 255.255.255.255
network ABC.DEF.GHI.0
broadcast ABC.DEF.GHI.JKL
gateway 10.255.255.1
# static routes
up route add –net 10.255.255.1 netmask 255.255.255.255 dev eth0
up route add –net 0.0.0.0 netmask 0.0.0.0 gw 10.255.255.1 dev eth0 

Enter your main IP address at IPADDR and BROADCAST. Enter your main IP address and the number 0 at NETWORK.

Apply the rest of the settings as indicated above.

Step 2

To add your additional IP as an alias (eth0:0), enter the following:

auto eth0:0
iface eth0:0 inet static
address ABC.DEF.GHI.JKL
netmask 255.255.255.255
network ABC.DEF.GHI.0
broadcast ABC.DEF.GHI.JKL
gateway 10.255.255.1
Step 3

To restart the network, enter the following command:

/etc/init.d/networking restart