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:
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:
iface lo inet loopback
iface lo inet6 loopback
iface enp2s0 inet static
# route 184.108.40.206/27 via 220.127.116.11
up route add -net 18.104.22.168 netmask 255.255.255.224 gw 22.214.171.124 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
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:
Address=10.4.0.0/27 – main IP server,
Address=10.4.2.1/27 – additional IP.
$ systemctl start systemd-networkd