A tip or two for VMware Fusion (OS X) guest networking

Before I get into this post too far, yes, I’m now a Mac user. Not exactly a fanboy yet, but my new employer let me choose between a Windows laptop and a MacBook for my work computer, so I chose–wisely. I’d been using Ubuntu on an HP laptop (ugh to HP) for a few years, so it seemed like a chance to try something new at no cost to me, which is my favorite cost.

As you can see from my other posts about virtualization, I’m a big fan of Virtualbox, but this post is about VMware Fusion, which was provided to me with my MacBook.

On to the tips…

I’ve been creating a testing environment for tacacs+ servers for a Cisco networking environment as well as Puppet server management, and I’m horrible with remembering IP addresses, unless there’s a very distinct pattern. When you use NAT in Fusion, addresses are assigned to guests VMs via DHCP in an automatically generated scope. The problem is, every time you boot your server you may get a new DHCP address! That sucks.

What to do?


You could create reservations, like this post and this post suggest, but since I’m eventually going to import the VMS I create into an ESXi host, it doesn’t hurt me to configure the guest’s network statically, as long as I know the range I can use for my guests.

If I look at my Mac’s dhcp.conf,

macbook:~ me$ more /Library/Preferences/VMware\ Fusion/vmnet8/dhcpd.conf

I see:

subnet 172.16.237.0 netmask 255.255.255.0 {
range 172.16.237.128 172.16.237.254;
option broadcast-address 172.16.237.255;
option domain-name-servers 172.16.237.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.237.2;
option routers 172.16.237.2;
}

I see that the DHCP scope for my NAT network doesn’t completely consume the whole /24 network–it only uses the “bottom” half. So, if I statically assign my guests addresses in the “top” half of the /24 network, my guests will still be on the same network.

So, if I configure my Ubuntu guest’s /etc/network/interfaces like this

iface eth0 inet static
address 172.16.237.100
netmask 255.255.255.0
gateway 172.16.237.2

and add an entry to my MacBook’s /etc/hosts like this

# my local VMs
172.16.237.100 guest01

my MacBook knows how to find guest01 by name, not just IP address!

macbook:~ me$ ping guest01
PING guest01 (172.16.237.100): 56 data bytes
64 bytes from 172.16.237.100: icmp_seq=0 ttl=64 time=0.345 ms
64 bytes from 172.16.237.100: icmp_seq=1 ttl=64 time=0.233 ms
^C
--- guest01 ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.233/0.289/0.345/0.056 ms

When I’m ready to import/convert my Fusion guest into our ESXi host, I just need to edit the guest’s /etc/network/interfaces again with the new IP address information.

Booyah!

Leave a Reply