1.修改网卡配置文件(操作前先备份一下该文件),/etc/sysconfig/network-scripts/ifcfg-enp0s3 ,如下:
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.1.101
NETMASK=255.255.255.0
NETWORK=192.168.1.0
NAME=enp0s3
DEVICE=enp0s3
ONBOOT=yes
DNS1=114.114.114.114
默认该文件中还有其他配置,可以都删除或注释。
2.修改网关配置文件,/etc/sysconfig/network,如下:
# Created by anaconda
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain
GATEWAY=192.168.1.1
3.重启服务
systemctl restart network