A network is a system of interconnected devices that allow resource sharing, exchange of files, and data communication. The network devices include servers, mainframes, computers, routers, hubs, bridges, and firewalls. The process of configuring, maintaining, and troubleshooting these network devices is known as Networking. An excellent example of a network is the Internet. There are two common types of networks;

  • Local Area Network (LAN) – confined to a small area like a school or a building.
  • Wide Area Network (WAN) – covers large geographic areas.

A network interface is a point of interconnection that connects a computer to a network. It is generally a component like a Network Interface Card(NIC) in hardware form but can also be implemented in software. Red Hat Enterprise Linux provides names for Network Interfaces based on firmware, topology, and location information to easily allocate and differentiate them.

In RHEL, the udev device manager for the Linux kernel manages device nodes in the /dev directory dynamically. By default, consistent device naming is enabled in Red Hat Enterprise Linux. The udev device manager generates device names based on the following schemes if consistent naming is enabled.

  • 1: The Device names incorporate firmware or BIOS-provided index numbers for onboard devices. An example is eno1.
  • 2: Device names incorporate firmware or BIOS-provided PCI Express (PCIe) hot plug slot index numbers. An example is ens1.
  • 3: Device names incorporate the physical location of the connector of the hardware. An example is enp2s0.
  • 4: Device names incorporate the MAC address. Example enx525400d5e0fb.
  • 5: The traditional unpredictable kernel naming scheme. Example eth0.

RHEL uses NetworkManager to manage network configurations. Some of its benefits include;

  • It creates temporary connections to provide network connectivity making Network management easier.
  • Easily set up connections to a user by managing the network through different tools like nmcli, nmtui, and GUI.
  • Maintaining the state of devices after a reboot.
  • Modify configuration options of a network.
  • Offering an API through D-Bus which allows to query and control network configuration and state.

There are several tools used in configuring networks in RHEL. They include

  • nmcli – A command-line utility to manage connections.
  • nmtui –  curses-based text user interface (TUI).
  • nm-connection-editor – A Graphical User Interface for Network Manager
  • control-center – A GNOME GUI for shell desktop users.

This guide takes you through the process of configuring Static IP Address on RHEL 9/CentOS Stream 9.

Getting started with nmcli Utility

nmcli is a command-line utility that is used to manage connections. You can use the nmcli utility with different options to display the required information.

To show device status in table format.

$ nmcli device
DEVICE  TYPE      STATE         CONNECTION 
ens19   ethernet  connected     Profile 1  
ens18   ethernet  disconnected  --         
lo      loopback  unmanaged     --

To display specific columns use the -f option.

$ nmcli -f DEVICE,STATE device
DEVICE  STATE        
ens19   connected    
ens18   disconnected 
lo      unmanaged 

Use the -t option to display information in a colon-separated format.

$ nmcli -t device
ens19:ethernet:connected:Profile 1
ens18:ethernet:disconnected:
lo:loopback:unmanaged:

Add a Connection with nmcli utility

Add a new network profile.

$ nmcli connection add con-name Connection1 ifname ens18 type ethernet
Connection 'Connection1' (e9938597-d4c2-4991-96d6-726b732ae621) successfully added.

Set the IPv4 address of the network profile.

nmcli connection modify Connection1 ipv4.addresses 192.168.200.46/24

Set the connection method to manual.

nmcli connection modify Connection1 ipv4.method manual

Set the IPv4 Default Gateways.

nmcli connection modify Connection1 ipv4.gateway 192.168.200.1

Set the IPv4 DNS server address.

nmcli connection modify Connection1 ipv4.dns "192.168.200.1"

Set the DNS search domain for the connection.

nmcli connection modify Connection1 ipv4.dns-search example.com

Activate the connection profile.

$ nmcli connection up Connection1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)

To display the status of the connection profiles, use the following command.

$ nmcli device status
DEVICE  TYPE      STATE      CONNECTION  
ens19   ethernet  connected  Profile 1   
ens18   ethernet  connected  Connection1 
lo      loopback  unmanaged  -- 

To display properties of a specific connection.

$ nmcli connection show Connection1
connection.id:                          Connection1
connection.uuid:                        e9938597-d4c2-4991-96d6-726b732ae621
connection.stable-id:                   --
connection.type:                        802-3-ethernet
connection.interface-name:              ens18
connection.autoconnect:                 yes
connection.autoconnect-priority:        0
connection.autoconnect-retries:         -1 (default)
connection.multi-connect:               0 (default)
.....

Use the ping utility to verify the host can send packets to other hosts.

$ ping 192.168.200.46
#Sample Output #
PING 192.168.200.46 (192.168.200.46) 56(84) bytes of data.
64 bytes from 192.168.200.46: icmp_seq=1 ttl=64 time=0.053 ms
64 bytes from 192.168.200.46: icmp_seq=2 ttl=64 time=0.029 ms
64 bytes from 192.168.200.46: icmp_seq=3 ttl=64 time=0.027 ms
64 bytes from 192.168.200.46: icmp_seq=4 ttl=64 time=0.028 ms
64 bytes from 192.168.200.46: icmp_seq=5 ttl=64 time=0.034 ms

To deactivate a connection, use the following command.

$ nmcli connection down Connection1
Connection 'Connection1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)

nmtui utility

You should have installed the NetworkManager tui utility package. If not use the following command.

sudo dnf install NetworkManager-tui

Start nmtui utility with the following command.

nmtui

The application opens as follows

Use arrow keys or TAB keys to move about the application.
use SHIFT+TAB to go back through the options.
Use the Space bar to toggle the status of checkboxes.
Press the Enter key to select an option.

Add a Connection using nmtui utility

Once the utility is started, Select Edit a connection. Select on Add button on the right side and press Enter to continue.

Select Ethernet as the connection type and press Enter.

Add the Profile name and Device name, Select Manual, and Fill in the fields with the connection details. Then select OK to save changes.

The new connection is displayed on the list as shown below. Select the Back button and press Enter to go back to the main options.

Select Activate a Connection to activate the new connection.

Select the new connection, and on the right, select the Activate button Press Enter. Then go back with the back button.

Select Quit and press Enter to exit the tool.

Display the status of devices

$ nmcli device status
DEVICE  TYPE      STATE      CONNECTION  
ens19   ethernet  connected  Profile 1   
ens18   ethernet  connected  Connection1 
lo      loopback  unmanaged  --

To display all settings of the connection profile

$ nmcli connection show Connection1
connection.id:                          Connection1
connection.uuid:                        36262c04-1f27-4cce-be8b-b277f2763038
connection.stable-id:                   --
connection.type:                        802-3-ethernet
connection.interface-name:              ens18
connection.autoconnect:                 yes
connection.autoconnect-priority:        0
connection.autoconnect-retries:         -1 (default)
connection.multi-connect:               0 (default)
connection.auth-retries:                -1
connection.timestamp:                   1660597847
...

Configure a device as Unmanaged

You can set the network manager to ignore certain devices. You can use the interface name, MAC address, or device type.

Temporarily set a device as Unmanaged

To temporarily set a device as unmanaged, First display a list of the devices available to identify the one you want to set as unmanaged.

$ nmcli device status
DEVICE  TYPE      STATE      CONNECTION  
ens19   ethernet  connected  Profile 1   
ens18   ethernet  connected  Connection1 
lo      loopback  unmanaged  --

Then use the following command to set it as unmanaged.

nmcli device set ens18 managed no

Then display the list of devices

$ nmcli device status
DEVICE  TYPE      STATE      CONNECTION 
ens19   ethernet  connected  Profile 1  
ens18   ethernet  unmanaged  --         
lo      loopback  unmanaged  --

Permanently set a Device as Unmanaged

To permanently set a certain device as unmanaged, identify the device you want to set as unmanaged with the following command

$ nmcli device status
DEVICE  TYPE      STATE      CONNECTION  
ens19   ethernet  connected  Profile 1   
ens18   ethernet  connected  Connection1 
lo      loopback  unmanaged  --

Create an unmanaged file with the following content

$ sudo vi /etc/NetworkManager/conf.d/99-unmanaged-devices.conf
[keyfile]
unmanaged-devices=interface-name:ens18

Reload Network Manager

sudo systemctl reload NetworkManager

Confirm the device status

$ nmcli device status
DEVICE  TYPE      STATE      CONNECTION 
ens19   ethernet  connected  Profile 1  
ens18   ethernet  unmanaged  --         
lo      loopback  unmanaged  --

Conclusion

We have seen how to configure static IP addresses using NMCLI and NMTUI utility tools on RHEL 9|CentOS Stream 9. We have also gone through the network interface device naming hierarchy and how to configure the NetworkManager to ignore certain devices temporarily and permanently.

LEAVE A REPLY

Please enter your comment!
Please enter your name here