VMWare Fusion: Access SharePoint App from Mac Host

If you are a SharePoint App (Add-In) developer who uses a Mac and VMWare Fusion for VMs, you may wonder whether you can access your app from host. May be you want to test your app in Safari on Mac, or may be, just may be your VM is too slow when Chrome running on it (that was my case ūüėČ ). For what ever the reason, if you want to access your app from Mac, this is the guide for you.

First step of this guide is basic configuration of your VM, SharePoint and host Mac OS to make it available.

Add network adapter¬†to your VM and set its connectivity type to NAT (Share with my Mac on settings). You don’t have to do this if you already have a NAT adapter.¬†Now if you goto Network Connections on Windows, you must see an adapter which have IP begins with 172.xxx.xxx.xxx.¬†If you want to use the subnet as it is, you can ignore next steps¬†and¬†make IP address static on it to make sure it won’t change later. Remember to add the default gateway¬†when you add static IPs.
vmware-fusion-sp-app-on-mac-static-nat-ip

To change the subnet of your network adapter, you have to update internal settings of the NAT adapter. When you set connectivity type to NAT in any network adapter, it automatically point to vmnet8 internal adapter. What we are going to do is to update its settings so that you can add subnet mask you want.

  1. First turn off all the VMs running and quit VMWare Fusion
  2. Goto folder
    In Fusion 4.x and above:  /Library/Preferences/VMware Fusion/
    In Fusion 3.x and earlier:  /Library/Application Support/VMware Fusion/
  3. Open networking file and update subnet and mask as appropriate
  4. Goto folder  vmnet8  and open  nat.conf
  5. Update NAT gateway address which aligned to above subnet and mask
  6. If you are using Fusion 4.x, just start VMWare Fusion, 3.x and below, run below command

    Note: When using 4.x and above, do not use the boot.sh –restart command because it may result in unexpected behaviors. Instead, restart Fusion.
  7. Goto SharePoint VM, make NAT network adapter configuration static and update IP and gateway IP which aligns to above configuration.
  8. Disable firewall settings or allow access from host to Windows.
  9. Run ping on your IP from terminal to make sure it works.

This is not required, but if you want to access one of your web application from IP, you can update alternative access mapping of your web application to IP address and check whether it’s accessible via host. This is not recommended because, in this way you can only point to one web application, but you want all of your web applications accessible from the¬†host.

In my case, I have two completely different domains to web applications and apps.

Web applications: *.zeus.com
Apps: *.apps.contoso.com

What I want to do is to access both of these from my host. If you may notice, if I need to access only web applications and I only have few number of web applications, I can just update¬† hosts¬†file in Mac OS¬†and access it via host. But the issue is accessing apps, when you develop SharePoint Apps, each time you deploy it to SharePoint, it changes the domain name of the application, and we can’t add wild card domain names to¬† hosts¬†file. Because of this reason, we goto next stage of this tutorial.

  1. Install ¬†Homebrew¬†if you don’t have it on your Mac
  2. Install  dnsmasq , using this tool, you can setup your DNS resolver. Read more about dnsmasq here.
  3. Make sure you have  /usr/local/etc folder exists.
  4. Now I want to point above mentioned wildcard domains to my VM IP (172.16.36.132).

    Purpose of this command is to create  dnsmasq.conf file in   /usr/local/etc which have following lines.

    From this what is says is to point all traffic from *.zeus.com and *.apps.contoso.com to IP 172.16.36.132.
  5. Now we want Mac OS resolver to use  dnsmasq only for above wildcard domains. First we have to create folder which contains custom resolver domains.

    Add custom domain to use resolver in localhost.

    Now you have resolver pointed to  dnsmasq only for domains we need.
  6. Now we want to launch dnsmasq and restart it with Mac OS startup.
  7. Run pings on few¬†domain names under your wildcard domains to see the beauty. ūüėČ

Now you can peacefully try your SharePoint domains from Mac OS browsers and verify your application works on all environments.