tedgustaf.se

Edit the Host File on Mac OSX 10.6 and point it to Windows 7 localhost in Parallels 6

Pointing out your local sites in the host file in Windows is easy but I found out it wasn’t that obvious on Mac. Especially when you need to point to localhost on your Windows machine running in Parallells. This is how I did it.

  • Patrik Totero
  • 4 March 2011
  • 0

How about that awesome word spamming title? Sweet!

Being a Mac user, otherwise obvious things becomes hard when developing in a .Net environment. Since I have to use Visual Studio,  I need to work in Windows parallel to  OSX. So I deiced to go for Parallels 6 and install Windows 7. Basically I use Windows for two things only; work with Visual Studio .Net projects and test the websites in Internet Explorer.

Pointing out your local sites in the host file in Windows is easy but I found out it wasn’t that obvious on Mac. Especially when you need to point to localhost on the Windows machine running in Parallells. This is how I did it.

Get the Windows Virtual Machine IP address

This might be usefull for Mac users not familiar with Windows. Windows users can probably skip this part.

  1. In the dock, click the Parallels Deskotop icon and type cmd in the search field. Then hit Enter to open the Command Prompt.

    Screen shot 2011-03-04 at 11.53.57 AM
  2. In the Command Prompt, type ipconfig and hit enter. Now look for the Ethernet adapter Local Area Connection IPv4 Address. This is the IP that should go in your host file on the Mac.

    Screen shot 2011-03-04 at 11.55.49 AM 

Find the host file on the Mac and modify permissions

  1. Open up the finder and hit Cmd+shift+G to open up the “Go to the folder” popup. In the textfield type /private/etc.

    Screen-shot-2011-03-04-at-11.43
  2. Hit Go and you will get this

    Screen shot 2011-03-04 at 11.43.23 AM
  3. Now we need to edit the permissions on the Private and etc folders and on the host file located in the etc folder. Right click each one of them and choose Get info.

    Screen shot 2011-03-04 at 11.43.57 AMScreen shot 2011-03-04 at 11.45.40 AM
  4. Click the lock icon  in the bottom right corner in the info window. With the lock icon open click the plus sign in the bottom left corner to add your user. Now set the user Previlege to Read & Write. If you want you can click the lock icon again to close it.

    Screen shot 2011-03-04 at 11.44.33 AM
  5. (Optional) For easy access you can drag the host file to the left hand menu

    Screen shot 2011-03-04 at 11.43.08 AM

Point the host file to the Virtual Machine localhost

Use the IP address from before and point to desired hostnames on the Windows localhost. If everything went well you should be able to save the host file. Otherwise recheck the permissions.

Screen-shot-2011-03-04-at-11.57.02-AM

You’re done

Isn’t that sweet, now you don’t need to use that “ugly ass hell” IP address in the address bar in the browser anymore. Now you can use the same hostnames as you do on your Windows machine. Ler