1、打开网卡配置文件ifcfg-eth0:vim /etc/sysconfig/network-scripts/ifcfg-eth0
2、填写ip地址、子网掩码、网关、DNS等。其中“红色下划线的信息”是必须得有的
修改前的ifcfg-eth0:
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=enp0s3
UUID=5964afb2-be00-4486-977e-f8394c1c581f
DEVICE=enp0s3
ONBOOT=yes
修改后的:
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DNS1=192.168.1.1
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=enp0s3
UUID=5964afb2-be00-4486-977e-f8394c1c581f
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.0.104
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
3、重启网络服务。service network restart或/etc/init.d/network restart
4、ping测试