For novice users who are new to GNU/Linux for the first time, the first thing to consider is how to connect the machine to the Internet after installing the operating system. This article will tell you how to configure the IP address, subnet mask, gateway and DNS. There are several ways for reference. Whether you are a novice or a familiar, I believe you can quickly get started.
NetworkManager is a standard Linux network configuration tool suite, which supports server and desktop environments. Nowadays, most popular distributions support it. This set of network configuration tools is suitable for Rocky Linux 8 and later versions. If you want to configure network information graphically (i.e. the command line
nmtui), you only need to do this:
shell > dnf -y install NetworkManager NetworkManager-tui
shell > nmtui
|Edit a connection
|Activate a connection
|Set system hostname
You can use the Tab key or the ↑↓←→ key to select the specific If you want to change the network information, please select Edit a connection and then Enter. Select a different network card and select Edit.. to edit.
For IPv4, if it is to obtain network information with DHCP, you only need to select IPv4 CONFIGURATION <Automatic>, and run in your terminal
systemctl restart NetworkManager.service. This will work in most cases. In rare cases, you need to disable and enable the network card for the change to take effect. For example:
nmcli connection down ens33,
nmcli connection up ens33
Manually fix network information¶
If you want to manually fix all IPv4 network information, you need to select <Manual> after IPv4 CONFIGURATION and add it line by line. For example, I like this:
Then click \< OK >, return to the terminal interface step by step, and execute
systemctl restart NetworkManager.service. Similarly, in rare cases, the network card needs to be switched on and off to take effect.
Change the way of configuration files¶
All RHEL 7.x or 8.x distributions, whether upstream or downstream, are configured in the same way. The configuration file of network information is stored in the /etc/sysconfig/network-scripts/ directory, and one network card corresponds to one configuration file. The configuration file has many parameters, as shown in the following table. Notice! The parameters must be capitalized.
In RHEL 9.x distributions, the location of the directory where the NIC configuration file is stored has been changed, i.e., /etc/NetworkManager/system-connections/. See here for more information.
shell > ls /etc/sysconfig/network-scripts/
|System logical device name
|Whether the network card starts automatically with the system, you can choose yes or no
|Network card interface type, usually Ethernet
|The way to obtain ip, it can be DHCP dynamic acquisition, or static manual configuration using static
|The ip address of the network card, when BOOTPROTO=static, this parameter will take effect
|Hardware address, ie MAC address
|Decimal subnet mask
|Subnet mask, represented by numbers
|Gateway, if there are multiple network cards, this parameter can only appear once
|When it is yes, the DNS parameters defined here will modify /etc/resolv.conf; when it is no, /etc/resolv.conf will not be modified. When using DHCP, the default is yes
|The primary DNS is selected, it takes effect only when PEERDNS=no
|Alternative DNS, only effective when PEERDNS=no
|Whether to allow only browsers
|Whether ordinary users are allowed to control the network card device, yes means allow, no means not allowed
|Universal unique identification code, the main function is to identify the hardware, generally speaking, it is not necessary to fill in
|Proxy method, generally none, can be left blank
|If it is yes, it means that the device will be disabled after ipv4 configuration fails; if it is no, it means it will not be disabled.
|Whether to enable IPV6, yes to enable, no not to enable. When IPV6INIT=yes, the two parameters IPV6ADDR and IPV6_DEFAULTGW can also be enabled. The former represents the IPV6 address and the latter represents the designated gateway
|Whether to use IPV6 automatic configuration, yes means use; no means do not use
|Whether to give IPV6 the default route
|After IPV6 configuration fails, whether to disable the device
|Generate IPV6 address model, optional values are stable-privacy and eui64
After the configuration file is modified successfully, remember to restart the network card service
systemctl restart NetworkManager.service.
Recommended configuration for IPV4¶
Recommended configuration for IPV6¶
View network information¶
ip a or
nmcli device show
Author: tianci li
Contributors: Steven Spencer, Neil Hanlon