openEuler22.03LTS network card configuration

VmWare finished installing openEuler, modified the network card configuration file, restarted the network and reported an error service not found, because Euler uses nmcli to manage the network.

According to the experience of centos7, modify the ifcfg configuration file, restart the network fails, and report an error "network.service not found."

[root@localhost ]# systemctl restart network
Failed to restart network.service: Unit network.service not found.

Euler uses the NetworkManager tool to manage the network, so there is no network service, and Euler does not install net-tools by default, and you cannot use ifconfig to view the network configuration, which needs to be installed separately. According to the online statement, you can restart NetworkManager, and then try to restart.

[root@localhost ]# systemctl restart NetworkManager

There is no error in the process, but the IP has not been modified, and it is still the original configuration. Here you can use the "display all devices" command to view the current IP.

[root@localhost ]# nmcli dev show
GENERAL.DEVICE:                         ens32
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         00:0C:29:A1:5F:F2
......
IP4.ADDRESS[1]:                         192.168.50.200/24
IP4.GATEWAY:                            192.168.50.1
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 192.168.50.1, mt = 100
IP4.ROUTE[2]:                           dst = 192.168.50.0/24, nh = 0.0.0.0, mt = 100
IP4.DNS[1]:                             192.168.50.1

......

At this time, start to read the official Euler document: Configure the network , you can directly refer to "Configure the network through the ifcfg file-configure the static network" to modify the ifcfg file, and then restart, here is a difference from centos7 that the mask does not allow NETMASK, It must be represented by PREFIX, otherwise restarting NetworkManager will not take effect. In fact, as long as you use it strictly according to the configuration file in the official document, there is no problem. After modifying the configuration file, you can directly restart it to take effect:

[root@localhost ]# systemctl reload NetworkManager

In addition, you can also use the nmcli command to modify the network configuration. Personally, I feel that it is not as effective as modifying the configuration file. It is more troublesome to remember the command configuration, but it is very detailed. The main operations are as follows: 

1. Display all devices (see above for results)

[root@localhost ]# nmcli dev show

2. Display device status

[root@localhost ]# nmcli dev status
DEVICE TYPE STATE CONNECTION 
ens32 ethernet connected ens32      
lo loopback unmanaged --     

3. Show all connections  

[root@localhost ]# nmcli con show
NAME   UUID                                  TYPE      DEVICE 
ens32  12c810a2-f0a3-444b-9ba3-db5578dfe9d9  ethernet  ens32

4. Configure static connection

[root@localhost ]# nmcli con add type ethernet con-name net-static ifname enp3s0 ip4 192.168.0.10/24 gw4 192.168.0.254

5. Configure DNS

[root@localhost ]# nmcli con mod net-static ipv4.dns "8.8.8.8 114.114.114.114"

6. Activate new network connection

[root@localhost ]# nmcli con up net-static ifname enp3s0

 

 

Guess you like

Origin blog.csdn.net/qq_38084281/article/details/127510526