19.05.2023

Configuring the network interface on Debian

Cloud servers are often collected in common logical infrastructure for interaction: application servers can be assembled into a cluster, DB servers handles read\writes requests from another servers, backup software connects to target nodes, VPN servers processing clients’ traffic etc.

Cloud server is accessible after installation via public IP address – this is obviously convenient for administration. Meanwhile, network channel has limitation which can be as obstacle for transferring big amount of data between servers.

Instead of using public IP it is possible to create isolated (local) network and connect needed servers to it for intercommunication. Bandwidth is much higher in local network and allows transferring more traffic from server to server.

New network interface is created once a server is connected to a local network. It is even possible to create server without public IP and connect it directly to a local network – in this case server will not be accessible from outside.

Creating isolated networks as well as routed ones is possible for vStack cloud and VMWare cloud. Additionally, VMWare allows creating public networks.
Debian 11 is setting up network connections with using config files in /etc/network/ directory.

In previous versions the settings for network interface were set in single file /etc/network/interfaces. In version 11 this file exists and has the only string (besides comments):

It specifies that real settings will be taken from files resided in /etc/network/interfaces.d/ directory.

The same approach of splitting a single configuration file into separate ones for each interface is used as for some other system software. Mistake\typo in any file will not cause a common network failure. It is also easy to copy prepared config file or delete it if not needed anymore.

Example of simple configuration with static IP

Public IP is assigned to enp0s5 interface, and new interface enp0s6 in appeared without settings after connection to the local network:

Usually, static IP addresses are assigned on servers. To assign IP 172.16.61.10 to interface enp0s6 new file /etc/network/interfaces.d/enp0s6 has to be created with the following content:

auto enp0s6
iface enp0s6 inet static
address 172.16.61.10/24
mtu 1500

With these settings interface enp0s6 will be active when OS is started.

To apply it network systemd service has to be restarted:

systemctl restart networking

Running again command “ip a” shows that IP is assigned correctly:

If there are other servers already connected to the same local network than accessibility of IP 172.16.61.10 can be checked after these steps. Otherwise, add any server and ensure it can communicate with local addresses instead of public.

You may be also interested in