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.
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.
- First turn off all the VMs running and quit VMWare Fusion
- Goto folder
In Fusion 4.x and above: /Library/Preferences/VMware Fusion/
In Fusion 3.x and earlier: /Library/Application Support/VMware Fusion/
networking file and update subnet and mask as appropriate
12answer VNET_8_HOSTONLY_NETMASK 255.255.255.0answer VNET_8_HOSTONLY_SUBNET 172.16.36.0
- Goto folder vmnet8 and open nat.conf
- Update NAT gateway address which aligned to above subnet and mask
123# NAT gateway addressip = 172.16.36.2netmask = 255.255.255.0
- If you are using Fusion 4.x, just start VMWare Fusion, 3.x and below, run below command
Shell1sudo ./Macintosh HD/Library/Application\ Support/boot.sh --restart
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.
- Goto SharePoint VM, make NAT network adapter configuration static and update IP and gateway IP which aligns to above configuration.
- Disable firewall settings or allow access from host to Windows.
- 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
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.
- Install Homebrew if you don’t have it on your Mac
dnsmasq , using this tool, you can setup your DNS resolver. Read more about
Shell1brew install dnsmasq
- Make sure you have
/usr/local/etc folder exists.
1mkdir -p /usr/local/etc
- Now I want to point above mentioned wildcard domains to my VM IP (172.16.36.132).
Shell12echo "address=/.zeus.com/172.16.36.132" >> /usr/local/etc/dnsmasq.confecho "address=/.apps.contoso.com/172.16.36.132" >> /usr/local/etc/dnsmasq.conf
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.
- 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.
1sudo mkdir -p /etc/resolver
Add custom domain to use resolver in localhost.
Shell12sudo sh -c 'echo "nameserver 127.0.0.1" > /etc/resolver/zeus.com'sudo sh -c 'echo "nameserver 127.0.0.1" > /etc/resolver/apps.contoso.com'
Now you have resolver pointed to dnsmasq only for domains we need.
- Now we want to launch
dnsmasq and restart it with Mac OS startup.
1sudo brew services start dnsmasq
- 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.