In order to use the additional addresses on the server the package “iproute” and service program “ip” are needed. Configuration with alias interfaces (such as eth0:1, eth0:2 etc.) are outdated and should no longer be used.

To add an address please run:

$ ip addr add 10.4.2.1/27 dev enp2s0 

10.4.2.1 – additional IP,
enp2s0 – name interfaces.

To determine the name of the network interface, run:

$ ifconfig

This method is the simplest and fastest, however, after rebooting the server, the settings are not saved and the additional IP will not be available.

To permanently configure an additional IP, add the following lines to the /etc/network/interfaces file under the appropriate interface (for example, “enp2s0”):

up ip addr add 10.4.2.1/32 dev enp2s0
down ip addr del 10.4.2.1/32 dev enp2s0


The config should look something like this:

source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback
iface lo inet6 loopback

auto enp2s0
iface enp2s0 inet static
address 10.4.0.0
netmask 255.255.255.224
gateway 148.251.82.97
# route 148.251.82.96/27 via 148.251.82.97
up route add -net 148.251.82.96 netmask 255.255.255.224 gw 148.251.82.97 dev enp2s0

up ip addr add 10.4.2.1/27 dev enp2s0
down ip addr del 10.4.2.1/27 dev enp2s0

iface enp2s0 inet6 static
address 2a01:4f8:202:5264::2
netmask 64
gateway fe80::1

To apply the settings, restart the service:

$ service networking restart

Network setup through systemd-networkd.

Starting with versions of Debian 8 and Ubuntu 16.04, it is possible to use the systemd-networkd daemon. You need systemd version 210 and higher. You can check the version using the command:

$ systemctl –version

If the network is configured using /etc/network/, you must rename the interface file under a different name so that it is not used after setting up systemd-networkd:

$ mv /etc/network/interfaces /etc/network/interfaces.save

Then add systemd-networkd to the system startup, but do not start the service, because the network is not yet defined in systemd-networkd:

$ systemctl enable systemd-networkd

All configuration files are stored in /etc/systemd/network. Please note that case is important in configuration files.

Creat file enp2s0.network:

[Match]
Name=enp2s0


[Network]
Address=10.4.0.0/27
Address=10.4.2.1/27
 Gateway=148.251.82.97

Address=10.4.0.0/27 – main IP server,
Address=10.4.2.1/27 – additional IP.

Star systemd-networkd:

$ systemctl start systemd-networkd

Done!