虚拟机centos配置ip

时间:2021-08-23 03:23:54

涉及到三个配置文件,分别是:

/etc/sysconfig/network

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

/etc/resolv.conf

/etc/sysconfig/network

NETWORKING=yes
HOSTNAME=localhost.localdomain
#GATEWAY=192.168.203.2

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

DEVICE=eth0
HWADDR=00:0C:29:D3:B9:7E
TYPE=Ethernet
UUID=26efb74d-21a5-4e2e-824f-3f818066ee0a
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
#IPADDR=192.168.203.164
#NETMASK=255.255.255.0
#GATEWAY=192.168.203.2

/etc/resolv.conf

; generated by /sbin/dhclient-script
nameserver 192.168.0.251
nameserver 202.106.0.20

重启网络服务 service network restart

ping 自己能ping通,证明适配器没有问题,ping外网ping不通,证明网关设置有问题