Adding a Public IPv4 Address to a Linux Server (Debian)
Please use the “Print” function at the bottom of the page to create a PDF.
To configure an additional public IPv4 address in Debian, proceed as follows:
Requirements
You have assigned to your server in the Cloud Panel an additional public IPv4 address.
You have logged in to the server.
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:10.5.98.233 Bcast:10.5.98.233 Mask:255.255.255.255
inet6 addr: fe80::250:56ff:fe15:e8dc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
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:127.0.0.1 Mask:255.0.0.0
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)
Check which network interface is in use. In the example above, the eth0 network interface is active.
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
address ABC.DEF.GHI.JKL
netmask 255.255.255.255
broadcast ABC.DEF.GHI.JKL
network 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".
Note
The "auto lo" and "iface lo inet loopback" entries must not be changed!
Save your changes.
Restart the server.