Rocky Linux

How to Configure the Network Interface on Rocky Linux 9

Configuring the network interface is important because it helps establish a connection between network devices. It also allows the system to receive and send the data on the specific network. Moreover, various network services also require the network configuration to work properly.

Hence, you can manually configure the network interface in the system. Although there is a simple way of network configuration, many users always get confused about it. In this long guide, we will briefly explain the method to configure the network interface on Rocky Linux 9.

How to Configure the Network Interface on Rocky Linux 9

Before starting the configuration part, you need to get the information about the network interfaces through one of the following commands:

ip link

ifconfig

If you want to go for simpler results, run the following command:

ls /sys/class/net

Moreover, you can also check the IP address through the following command:

ip addr

Once you get the information about the currently available network interfaces, it is time to configure them. You can modify the /etc/network/interfaces file to configure the network interface.

You can change the parameters in this configuration file including the netmask, IP address, DNS servers, gateway, etc. Overall, the/etc/network/interfaces config file has an essential value in the system because it is the central location to set up and manage the network interface.

Let’s take an example to configure the static and dynamic IP in the /etc/network/interfaces config file. For static IP, use the following details for the config file:

TYPE=Ethernet

PROXY_METHOD=none

BROWSER_ONLY=no

BOOTPROTO=none

DEFROUTE=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=no

NAME=enp0s3

UUID=ID

ONBOOT=yes

IPADDR=IP Address

NETMASK=255.255.255.0

GATEWAY=Default Gateway

DNS1=8.8.8.8

DNS2=8.8.4.4

If you are unable to modify the previous details as per your system, here are the ways to find them:

For UUID, run the following command in the terminal:

nmcli -c

For NETMASK, you can use the following command:

ifconfig

To get the information about the GATEWAY, use the following command:

ip route

For the IP address, you can run the first command for static IP and the second command for dynamic IP:

ip addr show

In the previous result, inet 10.0.2.15 shows the static IP address.

ip addr show | grep 'inet.*brd'

Hence, the dynamic IP address of the system is 10.0.2.15. Now, it is time to create the config file including all the details:

TYPE=Ethernet

PROXY_METHOD=none

BROWSER_ONLY=no

BOOTPROTO=none

DEFROUTE=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=no

NAME=enp0s3

UUID=4504201a-a8ec-3f8d-a6e4-dfb53cdbb02c

ONBOOT=yes

IPADDR=10.0.2.15

NETMASK=255.255.255.0

GATEWAY=10.0.2.2

DNS1=8.8.8.8

DNS2=8.8.4.4

For the dynamic IP, you need to change the BOOTPROTO from none to dhcp, as shown in the following:

TYPE=Ethernet

PROXY_METHOD=none

BROWSER_ONLY=no

BOOTPROTO=dhcp

Finally, run the following command to restart the network system and finalize the changes:

sudo systemctl restart NetworkManager

Conclusion

This is all about configuring the network interface on Rocky Linux 9. We explained almost everything that you need to create a config file for static and dynamic IP accordingly. We recommend that you use the commands carefully, or you may get major errors while accessing the network through the system.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.