Go to the profile of  Leo
Leo
why do i need a bio? they are painful to write.
4 min read

How to setup Parallels to communicate with Windows in Mac

How to setup Parallels to communicate with Windows in Mac

I decided to have my development environment in Windows, because Mono is still buggy in my experience. I see > 100% CPU utilization that caused the runtime to just maximize my CPU threads. I didn't bother looking deeper into it, and decided to move back to Windows runtime.

I am going to run F# Suave and Fable. I thought it would be trivial to just start up the Windows Virtual Machine, run the application, and connect through Safari in Mac. However, I ended up spending more time that I expected just to diagnose the problem.

There are multiple solutions out there that I found such as:

Internet Solution one

Also I've configured in parallels:

Configure - hardware - Network adapter 1: Default Adapter
Preferences - network - connection type - shared networking
Edit: For Parallels 8

Configure > Hardware > Network adapter 1: Default Adapter
Preferences > Advanced > Network: Change Settings > Shared

Internet Solution two

Edit Mac Hosts file to include this line: 198.168.x.x Guest_Computer_Name (please note that the IP address equals the virtual machine's IP)

open Terminal application (Finder/Applications/Utilities/Terminal)
execute these commands one by one and hit Return/Enter after each command:
sudo su

(enter the password for your Mac user account, you will not see the letters)
vim /etc/hosts  

Now you are able to edit the file:
press i key to invoke "insert" mode of the text editor (vim)
write the following:
198.168.x.x Guest_Computer_Name    
press Esc button in order to exit "insert" mode
press Shift+Z Shift+Z to save the file and exit it.
Once you have done editing, please try to connect to Guest's IIS from Host's browser.

I really didn't like the starting solution that they gave me to turn off Windows Firewall, so I kept that enabled. Depending on the web server you are going to run, you might need different configuration and different steps. I will only list the following steps for the following web servers:

  • Suave
  • IIS Express

Setting up Parallels and Windows Firewall

  • Open Parallels Desktop Control Center
  • Go to Hardware tab, then Network 1, and choose Shared Network 1
  • Open Windows Firewall and click Advanced settings
  • On the left panel, click on Inbound rules, then click New Rule on the right panel
  • Select port as the type of rule
  • Select TCP, and specify the port that you want to open
  • Select allow the connection
  • Keep the default checked checkboxes
  • Give it a name and hit finish

Setting up Suave

  1. Open up the file where your Suave file resides
  2. Under config add a binding 2
let config =
  { defaultConfig with
      bindings =
        [ HttpBinding.mkSimple HTTP  "0.0.0.0" 8083
        ]
    }

Setting up IISExpress with Visual Studio 2015

C:\Users\leoluis\Documents\Visual Studio 2015\Projects\WebApplication1\
  • Go to .vs folder
  • Search for <binding>
  • By default, you should see similar
<site name="WebApplication1" id="2">  
        <application path="/" applicationPool="Clr4IntegratedAppPool">
          <virtualDirectory path="/" physicalPath="c:\users\leoluis\documents\visual studio 2015\Projects\WebApplication1\WebApplication1" />
        </application>
        <bindings>
          <binding protocol="http" bindingInformation="*:3854:localhost" />
        </bindings>
</site>  
  • Add the following tag 3
<binding protocol="http" bindingInformation="*:3854:*" />  
  • Run Visual Studio 2015 as Administrator 4

Mapping Windows Virtual Machine to a host name

If you want to be able to access the virtual machine not just through IP address, then you can map its IP to a hostname. This is not recommended for production and you should go map this to your own DNS.

  • Open windows command line in Windows
  • Type the following command:
ipconfig
  • Get the IPv4 Address
  • Open terminal in Mac
  • Type the following command:
sudo nano /private/etc/hosts
  • Under the existing items, add the IP address and hostname you want to call your Windows Machine

After doing all these setups, you should be able to communicate to your Windows Machine. You can test it out by running a web server in Windows, and open Safari in Mac, and type http://{host-name}:{port}, and your http request should get a response.

Notes

1. The reason why I chose Shared Network is because I want to be able to access my Mac files out of the box without further configuration. More on this can be found here
2. The reason why it's 0.0.0.0 is because it means "listen on every available network interface". More on this can be found here
3. The most interesting part is changing localhost to *. More information can be found here
4. I can only guess that due to security issues and how Windows UAG are designed. A helpful article can be found here