centos 7下修改IP地址为静态
1.修改ip地址
编辑 /etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost /]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
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=eth0
UUID=a0fe90c4-019c-40e5-bb00-de65b4ebd42c
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.31.161
NETMASK=255.255.255.0
GATEWAY=192.168.31.1
运行 service network restart
2.修改dns地址
编辑/etc/resolv.conf
修改文件内容
nameserver 114.114.114.114
nameserver fe80::ee41:18ff:fe0b:31c3%eth0
nameserver 240e:3a1:2c4e:d140::1
nameserver 114.114.114.114
常用dns地址
114.114.114.114
114.114.115.115
223.5.5.5 阿里
223.6.6.6 阿里
180.76.76.76 百度