Mac-VMwareFusion固定IP、网段
描述
- VMware Fusion 安装完CentOS7后,需要给CentOS7固定ip。
- 此处以固定IP段192.168.3.*为例
操作步骤(新版本)
- 完全退出VMware Fusion
Mac下,打开“终端”,进入如下目录:
/Library/Preferences/VMware\ Fusion/
- 先备份再修改
networking
- 先备份再修改
vmnet1/dhcpd.conf
- 先备份再修改
vmnet8/dhcpd.conf
- 先备份再修改
vmnet8/nat.conf
- 先备份再修改
注意:
- 备份配置文件不要以.bak结尾,会被覆盖,可以.default结尾
- vmnet1下配置的网段跟vmnet8下配置的网段不能一样,比如
192.168.65.0
和192.168.3.0
- 配置完不生效的话关闭VMware Fusion,再查看确认一下配置文件,没问题再重新打开VMware Fusion
- 固定IP参考下边旧版本,如果只有一台虚拟机自动分配起始IP,就不用固定了
操作步骤(旧版本)
Mac下编辑:
sudo vi /Library/Preferences/VMware\ Fusion/networking
修改vmnet8网卡的子网IP
# answer VNET_8_HOSTONLY_SUBNET 172.16.214.0 # 将上边一行修改为: answer VNET_8_HOSTONLY_SUBNET 192.168.3.0
Mac下编辑:
sudo vi /Library/Preferences/VMware\ Fusion/vmnet8/nat.conf
修改vmnet8网卡的默认网关
# NAT gateway address # ip = 172.16.214.2 ip = 192.168.3.2
Mac下编辑:
sudo vi /Library/Preferences/VMware\ Fusion/vmnet8/dhcpd.conf
绑定虚拟机Mac地址和IP。在 ####### VMNET DHCP Configuration. End of "DO NOT MODIFY SECTION" ####### 这一行之后添加如下:
host centos-01 { hardware ethernet 00:0C:29:CD:54:E0; fixed-address 192.168.3.200; }
centos-01 这个主机名要和虚拟机的名称对应(VMware中虚拟机的文件名)(经测不用文件名一样,自己对上号就行,关键是hardware一定要对应)
hardware为虚拟机的mac地址
添加完样例:
#subnet 172.16.214.0 netmask 255.255.255.0 { # range 172.16.214.128 172.16.214.254; # option broadcast-address 172.16.214.255; # option domain-name-servers 172.16.214.2; # option domain-name localdomain; # default-lease-time 1800; # default is 30 minutes # max-lease-time 7200; # default is 2 hours # option netbios-name-servers 172.16.214.2; # option routers 172.16.214.2; #} #host vmnet8 { # hardware ethernet 00:50:56:C0:00:08; # fixed-address 172.16.214.1; # option domain-name-servers 0.0.0.0; # option domain-name ""; # option routers 0.0.0.0; #} subnet 192.168.3.0 netmask 255.255.255.0 { range 192.168.3.128 192.168.3.254; option broadcast-address 192.168.3.255; option domain-name-servers 192.168.3.2; option domain-name localdomain; default-lease-time 1800; # default is 30 minutes max-lease-time 7200; # default is 2 hours option netbios-name-servers 192.168.3.2; option routers 192.168.3.2; } host vmnet8 { hardware ethernet 00:50:56:C0:00:08; fixed-address 192.168.3.1; option domain-name-servers 0.0.0.0; option domain-name ""; option routers 0.0.0.0; } ####### VMNET DHCP Configuration. End of "DO NOT MODIFY SECTION" ####### host centos-01 { hardware ethernet 00:0C:29:CD:54:E0; fixed-address 192.168.3.200; }
- 重启VMware Fusion,这一步很关键!否则不成功!