At Crush + Lovely, we use Railsmachine's Moonshine to automate the configuration of our servers. When writing our deployment recipes, VMWare Fusion's ability to take snapshots and rollback to these snapshots is a huge timesaver because it takes just seconds to roll a server image to it's original state.
When you're just configuring a single server, having a static IP address for your server image isn't too important, but when you're configuring multi-server setups, it can be useful to duplicate a number of server images and give each a static IP address so you can consistently deploy to them. While not documented well at all, it turns out that this is relatively easy to accomplish in four simple steps.
Let's say you have a guest machine with the name ubuntu-lucid-lynx-base
and you keep your guest machine images in ~/Documents/Virtual\ Machines/
. To determine the MAC address for this VM, you can run:
cat ~/Documents/Virtual\ Machines/ubuntu-lucid-lynx-base.vmwarevm/ubuntu-lucid-lynx-base.vmx | grep ethernet0.generatedAddress
If more than one line is returned, you're looking for the one with the value like 00:0c:29:9d:2a:38
.
Open /Library/Application\ Support/VMware\ Fusion/vmnet8/dhcpd.conf
. vmnet8
is the virtual interface for NAT networking in VMWare the guest machines. In this file, you'll see a subnet clause that looks something like this:
subnet 172.16.179.0 netmask 255.255.255.0 {
range 172.16.179.128 172.16.179.254;
option broadcast-address 172.16.179.255;
option domain-name-servers 172.16.179.2;
option domain-name localdomain;
default-lease-time 1800; # default is 30 minutes
max-lease-time 7200; # default is 2 hours
option routers 172.16.179.2;
}
Take note of the line starting with range
. The IP addresses you will assign your guest machines will need to fall outside that range. Find the line that looks like this:
####### VMNET DHCP Configuration. End of "DO NOT MODIFY SECTION" #######
Below that line, add a clause for your guest machine. It should look like this:
host ubuntu-lucid-lynx-base {
hardware ethernet 00:0c:29:9d:2a:38;
fixed-address 172.16.179.102;
}
Make sure the hardware ethernet
value matches the MAC address you found in step one, and the fixed-address
is an IP outside the range listed in the subnet
clause.
If you want to assign a fancy local hostname that refers to your guest machine, you can do so by editing your /etc/hosts
file. For instance, to assign the hostname ubuntu.local
to the guest machine we just setup, we could add the following line to our /etc/hosts
file:
172.16.179.102 ubuntu.local
Last thing to do is restart your VMWare daemons:
sudo "/Library/Application\ Support/VMware\ Fusion/boot.sh" --restart
- original source: http://crshlv.ly/rjlXdS
- note: These instructions have been tested on Snow Leopard only.
I've been trying to get this going for a couple days down OS X 10.9.1 (Maverick) w/ Ubuntu 12.04 LTS guest. My if I try this /etc/network/interfaces file on the guest...
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
...I don't get any IPs (as I would expect). When I try this...
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.78.10
netmask 255.255.255.0
network 192.168.78.0
broadcast 192.168.78.255
gateway 192.168.78.1
...things seem to work properly. I get the IPs I would expect and can SSH into the box. The problem is that it hangs when I try to get outside to the Internet. I've tried adding a "dns-nameservers 192.168.78.2" and that seems to get me a little farther as it lets me resolve domain names to their IP address. That said it won't connect to anything. I can't "telnet 8.8.8.8 53" or "curl google.com" or anything as it just hangs. I sort of feel at the end of the rope. Any ideas?