centos7如何设定固定ip

1、打开文件

vi /etc/sysconf ig/network-scripts/ifcfg-enp0s3

2、编辑文件

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=enp0s3
JUID=ad64525f-1779-476a-9fb1-bdd6494ed087
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.1.108
GATEWAY=192.168.1.1
DNs1=114.114.114.114
DNS2=223.5.5.5
NETTASK=255.255.255.0

变更项:

BOOTPROTO=static
ONBOOT=yes

新增项:

IPADDR=192.168.1.108
GATEWAY=192.168.1.1
DNs1=114.114.114.114
DNS2=223.5.5.5
NETTASK=255.255.255.0

3、重启生效

systemctl restart network

4、检查测试

ip a
cat /etc/resolv.conf
ping www.baidu.com

已发布

分类

来自

标签: