Rocky Linux is a community-driven Linux distribution based on Red Hat Enterprise Linux (RHEL) 8. In this article, we will show you how to configure networking on Rocky Linux 8.
There are two main ways to configure networking on Rocky Linux: using the nmcli
command-line tool or using the nmtui
text-based user interface. We will cover both methods in this article.
Configure Networking Using nmcli
The nmcli
command-line tool is a powerful utility for managing network connections and devices on Linux. To use nmcli
, you must first become the root user by running the su
command and entering the root password:
su
Next, you can use the nmcli
command to view a list of available network devices on your system:
nmcli device
This will list all the network devices on your system, along with their type and state (whether they are connected or disconnected).
To configure a network device, you need to first create a connection profile for it. You can do this using the nmcli
command with the connection add
subcommand, followed by the type of connection and the name of the connection profile. For example, to create a wired Ethernet connection profile called my-wired-profile
, you can use the following command:
nmcli connection add type ethernet con-name my-wired-profile
This will create a new connection profile for a wired Ethernet device. You can then use the nmcli
command with the connection modify
subcommand to set the IP address, netmask, gateway, and other network settings for the connection profile. For example, to set the IP address to 192.168.1.100
, the netmask to 255.255.255.0
, and the gateway to 192.168.1.1
for the my-wired-profile
connection profile, you can use the following command:
nmcli connection modify my-wired-profile ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1
Once the connection profile is configured, you can use the nmcli
command with the connection up
subcommand to activate the connection and connect to the network. For example, to activate the my-wired-profile
connection profile, you can use the following command:
nmcli connection up my-wired-profile
To verify that the connection is active and working, you can use the ping
command to send a test packet to a known host on the network, such as a router or another computer. For example, to ping the gateway (192.168.1.1
) that we configured earlier, you can use the following command:
ping -c 4 192.168.1.1
This will send four test packets to the gateway and display the result, indicating whether the connection is working properly.
Configure Networking Using nmtui
The nmtui
command is a text-based user interface for managing network connections on Linux. To use nmtui
, you can simply run the nmtui
command without any arguments:
nmtui
This will launch the nmtui
interface, which provides a menu-based interface for configuring network settings.