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

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


You have assigned to your server in the Cloud Panel an additional public IPv4 address.

You have logged in to the server.

Step 1

Enter the following command to display the statuses of the active and inactive network interfaces:

ifconfig -a

The active and inactive network interfaces will be displayed. Example:

ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:50:56:15:e8:dc
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::250:56ff:fe15:e8dc/64 Scope:Link
          RX packets:550 errors:0 dropped:0 overruns:0 frame:0
          TX packets:93 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:40700 (39.7 KiB)  TX bytes:17196 (16.7 KiB)

lo        Link encap:Local Loopback
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:142 errors:0 dropped:0 overruns:0 frame:0
          TX packets:142 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:47749 (46.6 KiB)  TX bytes:47749 (46.6 KiB)
Step 2

Check which network interface is in use. In the example above, the eth0 network interface is active.

Step 3

To add your additional IP as an alias, you must modify the record for the network interface used in /etc/network/interfaces. This file is responsible for managing the network configuration in Debian. Enter the following to make this change:

vi /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
auto eth0:0
iface eth0:0 inet static
name Ethernet alias LAN card
broadcast ABC.DEF.GHI.JKL

Enter your main IP address for the "address" and "broadcast" entries. Enter your main IP address and the number 0 for "network".

Please note: The "auto lo" and "iface lo inet loopback" entries must not be changed!

Step 4

Save your changes.

Step 5

Restart the server.