When managing your Linux servers, which can be located on-premises or in the cloud, a good understanding of the network component is key to any Linux/cloud administrator’s job. If you are studying for the Red Hat or Linux Foundation exam, this article will fit in your topics to be covered before taking the exam. The first step of this article is to understand how the network interfaces are labeled in a Red Hat Enterprise Linux. In my early days, the interfaces were eth0, eth1, and so forth (at that time we didn’t have WiFi). Nowadays, the systemd will use a specific logic to apply a name, and the names will be based on the firmware, topology, and location of the device.
Note: We can change the current policy to assign names to a device in a Linux system, including network devices. We should look at udevadm and its rules defined in the /etc/udev/rules.d directory.
Although reading a networking interface is harder than in the past, we know that they are static, and they will not change with any future hardware changes.
The naming convention will follow five schemas to assign a name to any given new network interface. Here is a summary of what is being used by systemd when a new adapter is added to the system:
- Assign the on-board firmware/BIOS index number. Example: eno1, where o represents on-board.
- Assign a PCI Express slot index number. Example: ens1, where s represents PCI Express.
- Assign a physical location. Example: enp0s9 (p as in physical).
- Assign the MAC address name to the interface. Example: en<MAC>.
- Assign the old-days naming convention if nothing else works. Example: eth0.
Now that we have an understanding and what to expect for any given network interface being added in our system, the next step is to understand which network interfaces we have available. There are several options to check for that information.
The first one is using the /sys folder, which is a sysfs virtual file system that has better support for hot-plugged devices. This new file system was introduced in the 2.6 kernel, and it has a structure that represents the devices attached to the current Linux system. To see all existing network devices in the current system, we can execute the following command:
ls -la /sys/class/net
Another option is using the nmcli (Network Manager Client) utility to list all existing devices. We can use the following command:
nmcli device status
Linux Network Manager
Red Hat Enterprise Linux uses Network Manager to manage all network devices and connections. All management of the network can be done using several network manager utilities (command line, text-based interface, and the graphical user interface).
There are some advantages in having systemd controlling the network area, and we can define the network interfaces as managed and control their state throughout server reboots.
We can check the Network Manager status using systemctl status NetworkManager (Item 1), as depicted in the image below. One of the benefits of the systemctl is the ability to query journal logs, and any device information is already displayed as part of the previous command.
Understanding devices and connections in the Linux Network Manager context
The best way to understand the difference between connections and devices in the Network Manager context is going through the process of adding a new interface to an existing server. In this article, we went ahead and added a couple of interfaces, for this section we are going to focus on the interface enp0s10.
The first thing is to list all existing network interfaces using nmcli device status and then checking the existing connections nmcli connection show. The nmcli has tons of parameters. Take advantage of the tab to autocomplete whatever you need. The autocompletion even fills out the names of connections when required.
A device by itself does not have an IP configuration. We need to associate a connection to it, and at the connection level is where we define all settings, including IP configuration.
Since we had a disconnected device, we will be connecting it, and as part of the process, a new connection will be created and assigned to the new device automatically. These following commands were used to perform the initial configuration.
nmcli device status nmcli device connect enp0s10 nmcli device status
All connections use a file in the /etc/sysconfig/network-scripts folder. Each file has all network configuration associated with the network interface, and the Network Manager will use that information when bringing up the connection.
The advantage of using a connection is that we can have different settings to the same network interface. When we activate a device for the first time, the first configuration is created, we can clone it and change settings or start from scratch. In these configuration files, we can define if they are going to be automatic when the server restarts.
If you want to list all settings of an existing configuration, the following command can be executed nmcli connection show <connectionName>. To edit an existing connection, use nmcli connection edit <connectionName>, and that command will open a nmcli prompt that allows changes in the settings.
After changing the settings, such changes are not applied automatically to the existing connection. We can bring the device up and down to refresh settings, or use nmcli device reapply <deviceName>
Using different flavors of Network Manager
Besides the nmcli tool, we have a TUI (text user interface) version that is useful when you need to change settings and don’t want to spend too much time on the command-line. You can start it using the nmtui command, and from the initial menu, we can manage connections, manage activation, and define the hostname of the server.
We can configure quickly static IP information, and if that network will be connected automatically. This interface also helps when activating connections.
If you are using the graphical user interface, you can always use nm-connection-editor, and you need to start the tool from the terminal. The interface lists all connections, and the administrator has the option to manage new and existing connections.
Featured image: Shutterstock
More Linux articles
- Setting up static IP address for Linux: Easier than you think
- Sending email from Linux terminal: Efficient and powerful solution
- Using the Linux command line for basic file handling
- PsychOS: A retro-styled Linux distro for your old PCs
- Reading text files the easy way with PowerShell and Linux bash shell