cd /etc/sysconfig/network-scripts/ #切换到网卡目录下
ls #查看网卡
vi ifcfg-enp1s0 #修改网卡目录

修改网卡启动ONBOOT=no改ONBOOT=yes(改完按esc键,输入:wq)

重启网卡服务:
systemctl restart network

安装net-tools yum安装
yum -y install net-tools

cd /etc/sysconfig/network-scripts/ #切换到网卡目录下
ls #查看网卡
vi ifcfg-enp1s0 #修改网卡文件

把BOOTPROTO=dhcp 改BOOTPROTO=static ONBOOT=no改ONBOOT=yes 尾部添加 IPADDR=(内网IP) NETMASK=(子网掩码) GATEWAY=(网关) DNS1=114.114.114.114 DNS2=8.8.8.8

(按esc键然后输入:wq 保存并退出)
然后重启网卡服务:
systemctl restart network

Ping测试百度
ping www.baidu.com

原文:https://www.cnblogs.com/sunboboy/p/15103204.html