Networking in VMware Fusion
I am in a long flight from Sydney to Dallas and was looking to kill some time. What can be better than writing a post for my blog :).
I have seen and helped many people struggling with networking in VMware Workstation or VMware Fusion. Common problems are unable to connect (ping/ssh/rdp) to the virtual machine from host or other VMs in the farm.
I am writing this post to configure networks in Virtual Machines such that you have access to it from host machine (where VMware Fusion is installed), from other VMs and to internet as well (if required).
I was a little worried whether my existing Kickstart and Puppet server created on VMware Workstation will funtion well or not after being imported in VMware Fusion or not, but everything worked seamlessly after making the right changes in the configuration file of VMware Fusion. It was a lot easy than I expected.
When someone installs a VM (Linux or Windows), the very first requirement if often to have the ability to SSH or RDP it.
In OS X, you just need to tweak one file and you're done. Before moving forward lets take a backup first. You can use GUI too, but I prefer CLI.
vikas@Vikas-MacBook-Pro:~$ ls -lrth /Library/Preferences/VMware\ Fusion/networking -rw-r--r-- 1 root wheel 461B 10 Jun 16:18 /Library/Preferences/VMware Fusion/networking vikas@Vikas-MacBook-Pro:~$ vikas@Vikas-MacBook-Pro:~$ sudo cp -pv /Library/Preferences/VMware\ Fusion/networking /Library/Preferences/VMware\ Fusion/networking-original /Library/Preferences/VMware Fusion/networking -> /Library/Preferences/VMware Fusion/networking-original vikas@Vikas-MacBook-Pro:~$
Now, it's time to decide what IP ranges you want for internal network (through which VMs will communicate to each other) and NAT IP network for internet access.
In this example, my internal network is running on 192.168.1.0 and for my NAT network I have chosen 192.168.181.0. VMware Workstation/Fusion routes the traffic through VMnet1 and VMnet8 adapters, these adapters act as gateways (kind of) for the Virtual Machines.
This is my networking file, modify yours as required.
vikas@Vikas-MacBook-Pro:~$ cat /Library/Preferences/VMware\ Fusion/networking VERSION=1,0 answer VNET1DHCP no answer VNET1DHCPCFGHASH 58A3410FF0D38B27B7F5462F8C7ZZJJS2C09630E answer VNET1HOSTONLYNETMASK 255.255.255.0 answer VNET1HOSTONLYSUBNET 192.168.1.0 answer VNET1VIRTUALADAPTER yes answer VNET8DHCP yes answer VNET8DHCPCFGHASH 84AA5E28557048D6CD188B0A40970B27B7D36096 answer VNET8HOSTONLYNETMASK 255.255.255.0 answer VNET8HOSTONLYSUBNET 192.168.181.0 answer VNET8NAT yes answer VNET8VIRTUALADAPTER yes vikas@Vikas-MacBook-Pro:~$
Here are the results, you're all set to edit or add networks of your Virtual Machine.
vikas@Vikas-MacBook-Pro:~$ ifconfig | grep -A 3 vmnet vmnet1: flags=8863mtu 1500 ether 00:50:56:c0:00:01 inet 192.168.1.1 netmask 0xffffff00 broadcast 192.168.1.255 vmnet8: flags=8863 mtu 1500 ether 00:50:56:c0:00:08 inet 192.168.181.1 netmask 0xffffff00 broadcast 192.168.181.255 vikas@Vikas-MacBook-Pro:~$
In VMware Fusion, the network card has to be configured as Private to my Mac for networking between VMs and Share with my Mac for internet access.
Let's take an example to make things clearer. I have a Debian 7.4.0 Virtual Machine on which I want to have two different networks.
This is a two step process, you need to add/edit network setting of VM and create routes. These steps should also work for all Debian family - Ubuntu, Mint, etc.
First Network Adapter (eth0)
Second Network Adapter (eth1)
Power on the VM and append below lines to /etc/rc.local
route del default gw 192.168.1.1 eth0 route add default gw 192.168.181.2 eth1
Thats it, you're ready to go. I will catch some sleep now.
Thanks for reading.