默认情况下,VMware Fusion中的虚拟机,网卡设置成DHCP(动态分配 )时,会分配一个IP地址,但这个IP通常很难记,如果我们想为某台虚拟机挑一个好记的IP地址,可以按如下步骤操作:
命令行下,输入
sudo vi /Library/Preferences/VMware\ Fusion/vmnet8/dhcpd.conf
该文件记录了动态分配的IP地址段,以及某个mac地址绑定的IP,参考下面的内容修改:
————————————————————————
allow unknown-clients;
default-lease-time 1800; # default is 30 minutes
max-lease-time 7200; # default is 2 hours
subnet 192.168.187.0 netmask 255.255.255.0 {
range 192.168.187.100 192.168.187.110;
option broadcast-address 192.168.187.255;
option domain-name-servers 192.168.187.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.187.2;
option routers 192.168.187.2;
}
host vmnet8 {
hardware ethernet 00:50:56:C0:00:08;
fixed-address 192.168.187.1;
option domain-name-servers 0.0.0.0;
option domain-name “”;
option routers 0.0.0.0;
}
host CentOS.01{
hardware ethernet 00:50:56:3C:30:4B;
fixed-address 192.168.187.101;
}
host centos.02{
hardware ethernet 00:50:56:38:33:7B;
fixed-address 192.168.187.102;
}
host centos.03{
hardware ethernet 00:0C:29:D3:29:77;
fixed-address 192.168.187.103;
}
host centos.04{
hardware ethernet 00:50:56:3a:93:0d;
fixed-address 192.168.187.104;
}
注意红色高亮部分,range行是动态分配的IP地址段。这样,我们就为centos.01~04这四台机器绑定了IP(注:虚拟机的mac地址,可以在虚拟机的网卡配置高级选项中查到,或者ifconfig/ipconfig查看),这个文件修改好后,保存退出,然后彻底退出vmare fusion,重新再启动vmware fusion,再启动各虚拟机,顺利的话,就能分配到理想的IP地址。
最后在mac本主系统、以及各虚拟机的hosts文件中做下映射,以后记起来就方便多了。
本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-06/144721.htm