Skip to content

Centos通过修改配置文件配置IP和DNS地址。

修改IP地址:

打开修改配置文件:

vim /etc/sysconfig/network-scripts/ifcfg-eth0

# Generated by dracut initrd
DEVICE="eth0"
ONBOOT="yes"
IPV6INIT="no"
IPV4_FAILURE_FATAL="no"
NM_CONTROLLED="no"
TYPE="Ethernet"
BOOTPROTO="dhcp"

改为如下内容:

# Generated by dracut initrd
DEVICE="eth0"
ONBOOT="yes"
IPV6INIT="no"
IPV4_FAILURE_FATAL="no"
NM_CONTROLLED="no"
TYPE="Ethernet"
BOOTPROTO="static"         //静态获取
IPADDR="192.168.1.10"          //IP地址
NETMASK="255.255.255.0"          //子网掩码
GATEWAY="192.168.1.254"          //网关地址

重启服务:

systemctl restart network

修改DNS:

vim /etc/resolv.conf

写入:

nameserver 114.114.114.114

Be First to Comment

发表评论

电子邮件地址不会被公开。