系统环境:
OS:CentOS Stream 9
CentOS Stream 9
Unlike previous versions CentOS
, there are no previous network setting related commands, such as:
service network start/restart/status
systemctl start/restart/status network
IP
The configuration file for setting the network card is also /etc/sysconfig/network-script
no longer found in the directory, so let’s see how to CentOS Stream 9
configure static IP
. Of course, the easiest way is to open the settings and modify them with a graphical interface. The operation steps are clear at a glance, and will not be described in this article.
1. Open the network card configuration file
CentOS Stream 9
Move the network card configuration file in /etc/NetworkManager/system-connections/
the directory , open the corresponding network card configuration file:
[imaginemiracle@localhost ~]$ sudo vim /etc/NetworkManager/system-connections/ens192.nmconnection
2. Modify configuration ipv4 item
When the file is opened, the default configuration should be as shown in the figure below:
configure the [ipv4]
item as manual mode, and set it to specified IP
:
[注]:在配置文件中,不要擅自添加空格,可能会造成无法识别。
3. Reload the network card configuration file
Reload the network card configuration file:
[imaginemiracle@localhost ~]$ sudo nmcli c reload
[imaginemiracle@localhost ~]$ sudo nmcli c up ens192
Use ifconfig
the command to view the configuration information of the network card, and the modification is successful.
This configuration is complete
Help
nmcli
Order