VM-Ware Fusion is a great tool for desktop virtualization and no doubt for me its “the” killer application in my work, the only annoyance is that a lot of great functionality lies hidden from the GUI and it is not obvious where to find documentation especially on the networking side.
A few month back I started work on a new project that involves several servers communicating amongst each other in classic web service based application. As I am on the road a lot virtualization of the multi server environment allows me take this set of servers with me on my mac book pro. Now the virtualization of the serves is as straight forward as installing any operating system on physical hardware what proved a little tricky was configuring the virtualized network.
Here is the list of requirements for the network:
- The virtual machines need be configured using DHCP. VMs IP addresses need to be assigned based on the VMs Mac address effectively giving the servers static IPs .
- The VMs will need to be able to have internet access.
- The host must be able to roam on different networks and always be assigned an IP with DHCP
- When required external user must be able to access the VM’s.
The following VM-Ware fusion tips fulfill the above requirements:
Customizing VM-Ware Fusion Network Settings:
On Mac OS X Leopard the configuration files for fusion can be found in the folder:
/Library/Application Support/VMware Fusion/
On the shell:
cd /Library/Application\ Support/VMware\ Fusion/
Within the VMWare Fusion each network hast its own settings folder. The NAT network is named vmnet8.
Assigning MAC based IPs to VMs with DHCP. (Love the acronym jungle that is IT)
The DHCP settings for the network are in the dhcp.conf file which is in the networks configuration folder. On a standard installation this file is write protected, also this file is overridden
when Fusion is updated to a new version so make sure you back up all changes you make to network setting prior to installing a new version.
cd /Library/Application\ Support/VMware\ Fusion/vmnet8 (We modify vmnet 8 which is the NAT network)
sudo chmod o+rw dhcp.conf (Change permissions to make the file writable)
sudo vim dhcp.conf
For each of the vm’s that you wish to assign a MAC bases ip ad the following section:
host myserverA {
hardware ethernet 00:0c:29:0f:86:eb;
fixed-address 172.16.216.11;
}
sudo /Library/Application\ Support/VMware\ Fusion/boot.sh --restart (Restart networking and pick up changes in the configuration file) (You MAY also need to restart OS X)
An example file looks like this:
allow unknown-clients;
default-lease-time 1800; # 30 minutes
max-lease-time 7200; # 2 hours
subnet 172.16.216.0 netmask 255.255.255.0 {
range 172.16.216.128 172.16.216.254;
option broadcast-address 172.16.216.255;
option domain-name-servers 172.16.216.2;
option domain-name "localdomain";
option routers 172.16.216.2;
}
host www {
hardware ethernet 00:0c:29:0f:86:eb;
fixed-address 172.16.216.9;
}
host mysql {
hardware ethernet 00:0c:29:6d:89:b2;
fixed-address 172.16.216.7;
}
Note:
You can also configure the network settings handed out by DHCP and a bunch of other stuff by altering this file.
Mapping Host Ports to Virtual Machines on a NAT network.
The NAT settings are configured in a file called nat.conf which is in the networks configuration folder. On a standard installation this file is write protected, also this file is overridden
when Fusion is updated to a new version so make sure you back up all changes you make to network setting prior to installing a new version.
cd /Library/Application\ Support/VMware\ Fusion/vmnet8 (We modify vmnet 8 which is the NAT network)
sudo chmod o+rw nat.conf (Change permissions to make the file writable)
sudo vim nat.conf
After the [incomingtcp] section add the port you want to map and where to map the port to. In this example requests to the host on port 80 are mapped to port 80 on a virtual machine with the ip address 172.16.216.9
80 = 172.16.216.9:80
sudo /Library/Application\ Support/VMware\ Fusion/boot.sh --restart (Restart networking and pick up changes in the configuration file) (You MAY also need to restart OS X)
An example file looks like this:
# Linux NAT configuration file
[host]
# NAT gateway address
ip = 172.16.216.2
netmask = 255.255.255.0
# or ip = 172.16.216.2/24
# enable configuration; disabled by default for security reasons
#configport = 33445
# VMnet device if not specified on command line
device = /dev/vmnet8
# Allow PORT/EPRT FTP commands (they need incoming TCP stream...)
activeFTP = 1
# Allows the source to have any OUI. Turn this one if you change the OUI
# in the MAC address of your virtual machines.
#allowAnyOUI = 1
[udp]
# Timeout in seconds, 0 = no timeout, default = 60; real value might
# be up to 100% longer
timeout = 60
[incomingtcp]
# Use these with care - anyone can enter into your VM through these...
# FTP (both active and passive FTP is always enabled)
# ftp localhost 8887
#8887 = 172.16.226.128:21
# WEB (make sure that if you are using named webhosting, names point to
# your host, not to guest... And if you are forwarding port other
# than 80 make sure that your server copes with mismatched port
# number in Host: header)
# lynx http://localhost:8888
80 = 172.16.216.11:80
# SSH
# ssh -p 8889 root@localhost
#8889 = 172.16.226.128:22
[incomingudp]
# UDP port forwarding example
#6000 = 172.16.226.128:6001
Most information for these tips and a great networking how to can be found here:
http://communities.vmware.com/message/718890#718890
http://communities.vmware.com/servlet/JiveServlet/download/718890-1931/VMware%20Fusion%20Network%20Settings%20-%20Part%201.pdf
http://communities.vmware.com/docs/DOC-2527