Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 3.24 KB  |  hits: 33  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # How to setup your VMWare Fusion images to use static IP addresses on Mac OS X
  2.  
  3. At [Crush + Lovely](http://crushlovely.com), we use [Railsmachine's](http://railsmachine.com) [Moonshine](http://github.com/railsmachine/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.
  4.  
  5. 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.
  6.  
  7. ## 1. Determine the MAC address of your guest machine
  8.  
  9. 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:
  10.  
  11. ```
  12. cat ~/Documents/Virtual\ Machines/ubuntu-lucid-lynx-base.vmwarevm/ubuntu-lucid-lynx-base.vmx | grep ethernet0.generatedAddress
  13. ```
  14.  
  15. If more than one line is returned, you're looking for the one with the value like `00:0c:29:9d:2a:38`.
  16.  
  17. ## 2. Add your static IP address to VMWare's `dhcpd.conf`
  18.  
  19. 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:
  20.  
  21. ```
  22. subnet 172.16.179.0 netmask 255.255.255.0 {
  23.         range 172.16.179.128 172.16.179.254;
  24.         option broadcast-address 172.16.179.255;
  25.         option domain-name-servers 172.16.179.2;
  26.         option domain-name localdomain;
  27.         default-lease-time 1800;                # default is 30 minutes
  28.         max-lease-time 7200;                    # default is 2 hours
  29.         option routers 172.16.179.2;
  30. }
  31. ```
  32.  
  33. 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:
  34.  
  35. ```
  36. ####### VMNET DHCP Configuration. End of "DO NOT MODIFY SECTION" #######
  37. ```
  38.  
  39. Below that line, add a clause for your guest machine.  It should look like this:
  40.  
  41. ```
  42. host ubuntu-lucid-lynx-base {
  43.     hardware ethernet 00:0c:29:9d:2a:38;
  44.     fixed-address 172.16.179.102;
  45. }
  46. ```
  47.  
  48. 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.
  49.  
  50. ## 3. Optional: Update your `/etc/hosts` file
  51.  
  52. 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:
  53.  
  54. ```
  55. 172.16.179.102 ubuntu.local
  56. ```
  57.  
  58. ## 4. Restart the VMWare daemons
  59.  
  60. Last thing to do is restart your VMWare daemons:
  61.  
  62. ```
  63. sudo "/Library/Application\ Support/VMware\ Fusion/boot.sh" --restart
  64. ```
  65.  
  66. * _original source_: http://crshlv.ly/rjlXdS
  67. * _note_: These instructions have been tested on Snow Leopard only.