In the Linux images of Clouding they use Netplan, systemd-networkd, or NetworkManager for network interface configuration. By default, it is configured on the servers for DHCP usage and up to four network interfaces (including the public interface). Therefore, if you need to enable more than three Clouding Private Networks (VPC) or assign addresses statically on a server, you will need to add it to the configuration.
On Ubuntu, Netplan is used, developed by Canonical, the company behind Ubuntu itself. It is a network configuration tool for Linux systems, which uses YAML files to define network settings. It works with NetworkManager and systemd-networkd backends, making it easy to manage complex networks and allowing quick changes with simple commands.
On RHEL-based systems, NetworkManager is used by default. NetworkManager is an open-source software project initially developed by Red Hat. Its main goal is to simplify network configuration and management on Linux-based operating systems. It provides both command-line and graphical interfaces to manage network connections. Therefore, it is possible to use nmtui, nmcli, or manually edit the configuration.
Debian currently uses systemd-networkd, a system daemon that manages network configurations. It detects and configures network devices as they appear; it can also create virtual network devices. This service can be especially useful for setting up complex network configurations for a container managed by systemd-nspawn or for virtual machines. It also works well for simple connections. Previously, Debian used ifupdown.
To configure a network interface to use DHCP in Netplan, follow these steps. First, open the Netplan configuration file. Netplan configuration files are located in the /etc/netplan/ directory. Typically, there is a file with a .yaml extension. Use your preferred text editor to open it, for example:
# nano /etc/netplan/01-netcfg.yaml
Edit the configuration file and ensure that the file content is set to use DHCP. An example configuration to add DHCP for eth4 would be:
network:
ethernets:
eth0:
dhcp4: true
critical: true
eth1:
dhcp4: true
optional: true
eth2:
dhcp4: true
optional: true
eth3:
dhcp4: true
optional: true
eth4:
dhcp4: true
optional: true
version: 2
To apply the configuration, save the changes and apply the new configuration using the command:
# netplan apply
This will configure the eth0 interface to automatically obtain an IP address via DHCP.
To configure a network interface with a static IP address in Netplan, follow these steps. First, open the Netplan configuration file:
# nano /etc/netplan/01-netcfg.yaml
Edit the configuration file to include the static configuration. An example for the eth4 interface could be:
network:
ethernets:
eth0:
dhcp4: true
critical: true
eth1:
dhcp4: true
optional: true
eth2:
dhcp4: true
optional: true
eth3:
dhcp4: true
optional: true
eth4:
addresses:
- 192.168.1.100/24
gateway4: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
version: 2
In this example:
- addresses defines the static IP address and the subnet mask.
- gateway4 specifies the default gateway.
- nameservers provides the addresses of the DNS servers.
To apply the configuration, save the changes and apply the new configuration with:
# netplan apply
This will configure the eth4 interface with the static IP address 192.168.1.100, the gateway 192.168.1.1, and Google's DNS servers. You can also add more addresses on the same interface, an example would be:
eth4:
addresses:
- 192.168.1.100/24
- 192.168.2.100/24
gateway4: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
By following these steps, you can configure the network interfaces on your servers with Netplan, both for automatic address assignment using DHCP and for static assignment.
nmtui (NetworkManager Text User Interface) is a utility that provides a text-based graphical interface to manage network connections on Linux systems. It is part of the NetworkManager-tui package and allows users to configure and manage network connections in a more intuitive and user-friendly way than using command-line commands or directly editing configuration files. By default, it is installed on RHEL-based distributions and to start it, simply run:
# nmtui
A graphical window will appear with a menu with several options:
- Edit a connection: Allows you to add, edit, or delete network connections.
- Activate a connection: Allows you to activate or deactivate existing network connections.
- Set system hostname: Allows you to change the system hostname.
It is a useful tool for configuring and managing network connections in Linux through a text-based graphical interface, simplifying the process for users who prefer not to use command-line commands or manually edit configuration files.
nmcli (NetworkManager Command Line Interface) is a command line tool used to interact with NetworkManager, a tool that simplifies network management on Linux systems. nmcli allows managing network connections and devices, as well as obtaining information about the status of networks.
First, to list all network devices and their current status, use the command:
# nmcli device status
For example, to automatically assign the address using DHCP to the eth1 interface:
# nmcli con add type ethernet ifname eth1 con-name dhcp-eth1 ipv4.method auto
And with the following command, bring it up:
# nmcli con up dhcp-eth1
On the other hand, to configure the eth1 interface with a static IP and gateway:
# nmcli con add type ethernet ifname eth1 con-name static-eth1 ip4 192.168.1.100/24 gw4 192.168.1.1
And to assign DNS servers to the interface:
# nmcli con mod static-eth1 ipv4.dns "8.8.8.8 8.8.4.4"
Finally, to bring the interface up:
# nmcli con up static-eth1
To configure eth1 to use DHCP, create or edit the file /etc/sysconfig/network-scripts/ifcfg-eth1:
# nano /etc/sysconfig/network-scripts/ifcfg-eth1
With the following structure:
DEVICE=eth1
BOOTPROTO=dhcp
ONBOOT=yes
To assign a static IP address:
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
Finally, restart the service to apply the changes:
# systemctl restart network
Using systemd-networkd, you can use Netplan or NetworkManager by installing them first or configure it manually. In the following section, we will only explain how to configure it manually, without using any tools.
With systemd, you can create different files for each interface or create a general one to assign all by DHCP. For example, you can create a single file in /etc/systemd/network/ and use "Match" with all:
# nano /etc/systemd/network/alldhcp.network
Adding the following:
[Match]
Name=eth*
[Network]
DHCP=yes
On the other hand, if you want to configure it statically, you will need to create an individual file per interface. For example, for eth1:
# nano /etc/systemd/network/10-eth1.networkThe structure would be as follows:
[Match]
Name=eth1
[Network]
Address=192.168.1.100/24
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=8.8.4.4
Finally, restart the service to apply the changes:
# systemctl restart systemd-networkd
Note that in later versions of Debian, ifupdown was used and the configuration was done in the directory /etc/network/interfaces*. Example of configuration:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
We hope this tutorial has helped you. If you have more questions, write to us at soporte@clouding.io Our Technical Support team will help you with whatever you need! 😉