VMware Fusion指定虛擬機IP

問題描述

VMware Fusion中虛擬機的IP老是不斷變化,致使本身搭建的Hadoop、Spark集羣的維護很是不方便, 因此就須要爲虛擬機指定IP地址。ios

解決方案

dhcpd.conf文件

dhcpd.conf 文件記錄了動態分配的IP地址段,以及mac地址綁定的IPvim

# Configuration file for ISC 2.0 vmnet-dhcpd operating on vmnet8.
#
# This file was automatically generated by the VMware configuration program.
# See Instructions below if you want to modify it.
#
# We set domain-name-servers to make some DHCP clients happy
# (dhclient as configured in SuSE, TurboLinux, etc.).
# We also supply a domain name to make pump (Red Hat 6.x) happy.
#


###### VMNET DHCP Configuration. Start of "DO NOT MODIFY SECTION" #####
# Modification Instructions: This section of the configuration file contains
# information generated by the configuration program. Do not modify this
# section.
# You are free to modify everything else. Also, this section must start 
# on a new line 
# This file will get backed up with a different name in the same directory 
# if this section is edited and you try to configure DHCP again.

# Written at: 07/02/2016 03:48:07
allow unknown-clients;
default-lease-time 1800;                # default is 30 minutes
max-lease-time 7200;                    # default is 2 hours

subnet 192.168.109.0 netmask 255.255.255.0 {
	range 192.168.109.128 192.168.109.254;
	option broadcast-address 192.168.109.255;
	option domain-name-servers 192.168.109.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.109.2;
	option routers 192.168.109.2;
}
host vmnet8 {
	hardware ethernet 00:50:56:C0:00:08;
	fixed-address 192.168.109.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" #######

說明: "range 192.168.109.128 192.168.109.254" 是動態分配的IP地址段。網絡

爲虛擬機指定 IP

編輯 dhcpd.conf 文件app

sudo vim /Library/Preferences/VMware\ Fusion/vmnet8/dhcpd.conf

在文件末尾添加如下配置dom

host master {
	hardware ethernet 00:0C:29:61:B0:BF;
	fixed-address 192.168.109.137;
}
host slave01 {
        hardware ethernet 00:0C:29:B8:B8:5c;
	fixed-address 192.168.109.139;
}
host slave02 {
	hardware ethernet 00:0C:29:0D:BE:68;
	fixed-address 192.168.109.138;
}

虛擬機的 MAC 地址能夠在 "網絡適配器 -> 高級選項" 中查看到, fixed-address 後面的 IP 地址就是爲虛擬機所指定的 IP 地址, IP 地址的範圍須要在 range 後面指定的IP地址段範圍內。oop

相關文章
相關標籤/搜索