1.进入目录 cd /etc/sysconfig/network-scripts
2.找到ifcfg-ens33文件,有可能不通,寻找ifcfg-开头的文件
3.编辑ifcfg-ens33
TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=dhcp 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=ens33 UUID=2e718c8b-82c3-44b6-8b47-c13ab29a826b DEVICE=ens33 ONBOOT=yes4.将ONBOOT = no 改为 ONBOOT = yes
5.重启网卡
service network restart6.用 ifocnfig 查看ip地址
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.184.128 netmask 255.255.255.0 broadcast 192.168.184.255 inet6 fe80::df42:1f5b:eaa8:2611 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:b3:a7:36 txqueuelen 1000 (Ethernet) RX packets 31235 bytes 45545507 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 12671 bytes 806181 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 220 bytes 19080 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 220 bytes 19080 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 07. 检查网络,成功PING网络
[root@localhost network-scripts]# ping www.baidu.com PING www.a. ) 56(84) bytes of data. 64 bytes from 115.239.210.27 ): icmp_seq=1 ttl=128 time=3.33 ms 64 bytes from 115.239.210.27 ): icmp_seq=2 ttl=128 time=5.25 ms 64 bytes from 115.239.210.27 ): icmp_seq=3 ttl=128 time=4.75 ms