C/C++教程

centos8如何重启网卡

本文主要是介绍centos8如何重启网卡,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1、查看系统

[root@centos8pc2 network-scripts]# hostnamectl
   Static hostname: centos8pc2
         Icon name: computer-vm
           Chassis: vm
        Machine ID: f021cde3a91b4a2688dbedfe0884e052
           Boot ID: ffbe1ee973aa4d44a7b8b9d1a58683f1
    Virtualization: vmware
  Operating System: CentOS Linux 8
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-240.el8.x86_64
      Architecture: x86-64

 

2、修该网卡配置文件

[root@centos8pc2 network-scripts]# vim /etc/sysconfig/network-scripts/ifcfg-ens160
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens160
UUID=77656063-2595-411d-8b36-49caab425c3e
DEVICE=ens160
ONBOOT=yes
IPADDR=192.168.3.10
NETMASK=255.255.255.0
GATEWAY=192.168.3.1
DNS1=119.29.29.29

 

3、重启网卡

[root@centos8pc2 network-scripts]# ifconfig | head -n 3
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.91  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::c0fe:36f:3a46:9188  prefixlen 64  scopeid 0x20<link>
[root@centos8pc2 network-scripts]# systemctl restart network
Failed to restart network.service: Unit network.service not found.
[root@centos8pc2 network-scripts]# nmcli c reload
[root@centos8pc2 network-scripts]# ifconfig | head -n 3
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.91  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::c0fe:36f:3a46:9188  prefixlen 64  scopeid 0x20<link>
[root@centos8pc2 network-scripts]# nmcli c up ens160
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
[root@centos8pc2 network-scripts]# ifconfig | head -n 3
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.3.10  netmask 255.255.255.0  broadcast 192.168.3.255
        inet6 fe80::c0fe:36f:3a46:9188  prefixlen 64  scopeid 0x20<link>
[root@centos8pc2 network-scripts]# cat /proc/version 
Linux version 4.18.0-240.el8.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)) #1 SMP Fri Sep 25 19:48:47 UTC 2020

 

这篇关于centos8如何重启网卡的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!