Host MacOSX connecting to Win7+.net servers on localhost.

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
iRetrograde
Posts: 3
Joined: 4. Jul 2012, 21:51

Host MacOSX connecting to Win7+.net servers on localhost.

Post by iRetrograde »

Hi there guys, how's it going?

I'm a bit of a newb when it comes to all of this and I'm having a bit of a hard time putting my finger on the issue here. I've read a ton of threads, the VirtualBox networking guide, done a ton of different tests and setups and haven't been able to find a solution.

I'm gonna open this post here so I can put more information (haven't posted yet so I can't post my connections).
iRetrograde
Posts: 3
Joined: 4. Jul 2012, 21:51

Re: Host MacOSX connecting to Win7+.net servers on localhost

Post by iRetrograde »

So, here is my setup and configuration.

My current setup is:
Host: Macbook Pro OSX 10.6.8
Guest: Windows 7 N
Virtual Box: 4.1.16 r78094
Connection: Bridged connection

What I'm trying to do is as follows:

I'm trying to run a C# server app with a SQl database on my guest machine and connect it from my Host and from other devices like an iPhone.

I've setup the guest machine with a bridged connection via airport and I manage to get an ip connection @ address 192.168.1.102 I can connect to the internet and whatnot so setting up a NAT connection (to me, based on my limited knowledge) seems redundant.

Ethernet adapter Local Area Connection:
IPv4 Address: 192.168.1.102
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.1.1

Now, when I run my guest machine, it all loads properly. After compiling my C# app and running the server, I run netstat -a -n so I can check to see what's listening:

TCP 127.0.0.1:49301 0.0.0.0:0 LISTENING
TCP 192.168.1.102:139 0.0.0.0:0 LISTENING

The :139 port are the default printer and usb ports, but nonetheless I have my actual IP in place and I can see that my C# server is there as well.

Now I've gone into Windows Firewall and also opened up port 49301 on my guest, windows 7 setup.

On my guest machine, when my C# server is running. I can access the server by going to 127.0.0.1:49301/Home as well as localhost: 49301 (as expected).

On my host machine (my mac osx), I can ping the Windows 7 virtual box connection by pinging 192.168.1.102 and I receive packets from it without a hitch.

Having said that, my guess is that since the guest server is running on the localhost, it's not the same as connecting it through the Windows 7 IP address. How do I go about connecting to my guest server (C# server) from my host box (mac osx)?

What I mean by this is that I would expect that I should be able to go into google chrome on my Mac OSX and type:

192.168.1.102: 49301/Home

And have everything connect properly. However, this doesn't work, even if I can ping that IP address and receive an answer.

I have also opened up my router firewall and I'm directing my global IP address to that specific network IP and port.

Example, in my router, I've redirected TCP/UDP connections via the 49301 port to 192.168.1.102. I'm guessing that this should also be allowing me to connect to the server from a remote connection (i.e. from a mobile device)?

What am I missing here? I'm not familiar with ssh connections, IIS, bridge connections or anything like that, I'm a bit more of a designer/developer and never had the "pleasure" of going deep in establishing all of these connections and ports.

I want to be able to establish the following tests to my server:
WORKS - Guest machine to Guest server - Opening Chrome from Win 7 and just typing localhost:49301/Home
WORKS - Host machine pinging guest machine - Ping 192.168.1.102 gets a response
DOESNT WORK - Host machine access guest server - Opening Chrome from Mac OSX and typing 192.168.1.102:49301/Home
DOESNT WORK - Remote machine accessing guest server - Establishing a connection from an iOS app to my guest server by connecting to my Ip actual address 174.7.X.Y: 49301/Home

If someone can help me out through this, I'd be extremely grateful!
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Host MacOSX connecting to Win7+.net servers on localhost

Post by Perryg »

Sounds like you need to bind the C# server app to the IP instead of the local loopback (localhost 127.0.0.1).
iRetrograde
Posts: 3
Joined: 4. Jul 2012, 21:51

Re: Host MacOSX connecting to Win7+.net servers on localhost

Post by iRetrograde »

Hey Perryg, thanks for your comment. That's exactly what it was, having said that, it took a while longer to figure it out.

I read a TON of posts regarding how to do this and basically, I was looking at all of the wrong places. You are right, my setup was mostly correct, but I overcomplicated a LOT of things that were unnecessary, so I decided to write a bit about it.

When it came to setting up the application. I was one of the many people that were screaming "You can only use localhost as your server". From there, all hell broken loose. Since I'm a complete noob (or was, I learned a lot these past few days) I kept thinking that the issue was with my host-guest setup, etc....

So, I removed all of my network drives, reset all of my information and started from scratch. I had the best results with bridged-connection since I received a 192.168.1.102 IP address (meaning that I had an assigned, local network, IP address) and debugged a connection to it.

Host machine IP: 192.168.1.118
Guest machine's IP: 192.168.1.102

Debugging #1 - Get a packet sniffer
I picked up a TCP packet sniffer (Wireshark) so I could verify that I was getting connections between my host and the guest.
I run Wireshark on my guest setup and from my host, I ping my guest's ip address

Great, that's the right setup and my host is communicating with guest!

I then start by setting up my Visual Studio project.
1. Open project in Visual Studio
2. Enable IIS Express (after installing it) in the Project View by selecting my project solution on the right, right clicking it, then clicking "Enable IIS Express".
3. Select the project in the Project Viewer, right click and select properties.
- I make sure that my start actions are pointing to the "Current Page".
- I make sure that I have "Use Local Web Server" instead of "Visual Studio Development Server"
- I enable IIS Express and tell the project url to be: http://localhost:8080/
- I do NOT override the application root URL

I save the project and close it.
I open up the applicationHosting.config file located in my computer's user folder. In my case, my PC is called Na-PC so I navigate to the User/Documents/IISExpress/config/applicationhost.config and go to the bindings section

I then remove the localhost from "*:8080:localhost" and leave it as follows:

<bindings>
<binding protocol="http" bindingInformation="*:8080:" />
</bindings>

One step that I added, is that I had a lot of problems keeping visual studio running with the right folder, so I opened up my .csproj and made sure that the IIS information and port was correct:

Do a search for <ProjectExtensions> and I make sure that:
<DevelopmentServerPort>8080</DevelopmentserverPort>
<IISUrl>http://localhost:8080/</IISUrl>

I can then run my application and the server comes up fine. At this point, I still can't connect to my server other than through localhost.

I then go to Windows Firewall and create a custom port setting target port 8080 and I make sure that it's set for all network setups (domain, private and public). I also go to my router's page and make sure that port forwarding for port 8080 is pointing to my GUEST's IP address (192.168.1.102).

At this point, I can go to my HOST machine and connect to my GUEST by typing the following on a browser:
http: //192.168.1.102:8080/

Or I can connect to the guest remotely (because I forwarded the port 8080 in my router to 192.168.1.102) by connecting to my real IP address. http: //174.7.XXX.YYY:8080/

Thanks a lot for the help guys. I chased a TON of different resources and it ended up being a LOT simpler than what many people have recommended. Having said that, I feel a lot more confident in my networking skills... 3 days later...

Cheers VirtualBox forums!
TimStyle
Posts: 1
Joined: 2. Mar 2014, 19:00

Re: Host MacOSX connecting to Win7+.net servers on localhost

Post by TimStyle »

You are super Perryg. Just some of your words that release all my problems. The same as iRetrograde, I have seen tons of solution out there, but no one works for me. Also big Thanks to iRetrograde for posting the issue and explaining your solution.
Cheers,
Timstyle
Post Reply