1. 首先取消使用Vmware动态主机设置服务
[Edit] -> [Virtual Network Editor ...] 打开面板,选中[VMnet8]。
如下,取消对[ Use local DHCP service to distribute IP address to VMs]的勾选。
2. 配置文件修改
涉及3个配置文件,如下
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/resolv.conf
具体修改如下
GATEWAY # 网关
BOOTPROTO # 类型 将“dhcp”修改为“static”
IPADDR # 需要固定的IP
NETMASK # 子网掩码
DNS1 # DNS
nameserver # 这个可以忽略
[[email protected] ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain
GATEWAY=192.168.78.2
[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
# BOOTPROTO="dhcp"
BOOTPROTO="static"
IPADDR=192.168.78.145
NETMASK=255.255.255.0
HWADDR="00:0C:29:DE:93:80"
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="ba62d2e6-d078-4bb7-b8c4-d571a63ae836"
DNS1=192.168.78.2
[[email protected] ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.78.2
[[email protected] ~]#