accessing http address of host

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
mistafeesh
Posts: 4
Joined: 4. Apr 2012, 16:40

accessing http address of host

Post by mistafeesh »

Hi, hopefully this is a simple query but I wasn't getting anywhere googling or searching the documentation.

I want to be able to access the webserver on my OSX host from my windows 7 virtual machine to test websites in IE. How do I do that? When I enter the network name (eg mymac.local) I get a not found error. I can get to it with the IP address but it's not practical for this computer to have a static IP address and I need to be able to do this even if I'm not connected to a network.

Thanks
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: accessing http address of host

Post by mpack »

It should work with bridged or host only network modes. Of course implementing a DNS server (or simpler substitute) is another matter and beyond the scope of these forums. You should check out some networking forums: the same techniques apply whether the PCs concerned are virtual or not, meaning it's not a VirtualBox discussion.
mistafeesh
Posts: 4
Joined: 4. Apr 2012, 16:40

Re: accessing http address of host

Post by mistafeesh »

Hi, I'm still a bit confused I'm afraid (happens easily!)
I don't need to implement a DNS server or anything like that. I just need a reliable way of connecting to the webserver on the host computer.
I've tried messing around with the network adapter settings in virtualbox but I don't really know what I'm aiming for - I'm new to the whole virtualisation thing! I've tried using bridged mode but can't access the host's network address that is available to other computers on the network. In the manual it says there is limited functionality when using this on a mac that's connected via wifi. (http://www.virtualbox.org/manual/ch06.html#idp11897104)
When I try to go to 'Host Adapter' there is nothing to select in what looks like it should be a list of adapters - I have no idea how to rectify this!

Hopefully someone can shed some light for me?
Thanks again,
Dan
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: accessing http address of host

Post by Perryg »

I can get to it with the IP address but it's not practical for this computer to have a static IP address and I need to be able to do this even if I'm not connected to a network.
This is really a multi answer question.
1) setup a second adapter to host-only and you will always be able to get to the host from the guest.
2) if you want to use friendly names instead of IP and don't have DNS you put the information in what ever Mac uses for its host file.
mistafeesh
Posts: 4
Joined: 4. Apr 2012, 16:40

Re: accessing http address of host

Post by mistafeesh »

Hi, do you mean I should set up a second physical network card? That's not practical as I'm using a laptop and it being a mac they don't include PCMCIA slots etc.

I'm not fussed about having network friendly names but surely there's some way of accessing the host's webserver from the client os. I don't even need to ever be able to access the outside world from in there - it's purely so I can check my sites work in internet exploder. At the moment I have to be on a network, find out my host computer's IP and enter it into the web address on the guest OS.

I'm confused that there isn't an easy way of doing this as I'd have thought it was a very common use for a virtual machine...
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: accessing http address of host

Post by Perryg »

mistafeesh wrote:Hi, do you mean I should set up a second physical network card? That's not practical as I'm using a laptop and it being a mac they don't include PCMCIA slots etc.

I'm not fussed about having network friendly names but surely there's some way of accessing the host's webserver from the client os. I don't even need to ever be able to access the outside world from in there - it's purely so I can check my sites work in internet exploder. At the moment I have to be on a network, find out my host computer's IP and enter it into the web address on the guest OS.

I'm confused that there isn't an easy way of doing this as I'd have thought it was a very common use for a virtual machine...
I'm talking about virtual network adapters not the physical adapter.
In the guests settings and Network. Click on the second adapter tab enable the second Virtual Adapter and set it to host-only.
Or if the guest does not need to ever get to the Internet you can just switch the 1st adapter to host-only.
See http://www.virtualbox.org/manual/ch06.html for additional help and information about Virtual Networking.
BillG
Volunteer
Posts: 5106
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: accessing http address of host

Post by BillG »

mistafeesh wrote:Hi, do you mean I should set up a second physical network card? That's not practical as I'm using a laptop and it being a mac they don't include PCMCIA slots etc.

I'm not fussed about having network friendly names but surely there's some way of accessing the host's webserver from the client os. I don't even need to ever be able to access the outside world from in there - it's purely so I can check my sites work in internet exploder. At the moment I have to be on a network, find out my host computer's IP and enter it into the web address on the guest OS.

I'm confused that there isn't an easy way of doing this as I'd have thought it was a very common use for a virtual machine...
What you have failed to realise is that, as far as networking is concerned, the host and the guest are completely different machines (and http is a network protocol). To access a website on one machine from another machine, the first requisite is that they are in the same network and the second is that the target machine is "reachable" from the other machine.

"Reachable" is a networking term which means pretty much the same as in ordinary English. It is possible fo two machines to be in the same network but not reachable, such as when they are in different IP subnets and there is no device to route between the subnets.

Using the default network setting (NAT), the guest is not reachable from the host. You need to use a network setting which will ensure that the guest is reachable from the host (ie in the same network and in the same IP subnet).

Once the guest is reachable from the host you can easily reach the website using the IP of the guest machine. You do not need to set up a name server.
Bill
BillG
Volunteer
Posts: 5106
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: accessing http address of host

Post by BillG »

After re-reading your original post I see that you want to access the host from the guest, not vice-versa. Sorry my discussion assumed the other way around. The same points still apply, but it should be even easier that way.

I would leave the current network setting in place (so that the guest accesses the Internet throuh NAT) but install a second NIC in the guest (from the VirtualBox Manager) and configure it to use Host Only. You should then be able to access the website on the host using http: //192.168.56.1 (which is the interface on the host which is the same network and subnet as the guest).
Bill
mistafeesh
Posts: 4
Joined: 4. Apr 2012, 16:40

Re: accessing http address of host

Post by mistafeesh »

aah fantastic! Finally we have liftoff! I was trying to set up the host only nic just within the virtual machine settings rather than the settings for virtualbox... I now have 2 nic in my virtual machine and as promised I can access the host with http: //192.168.56.1 even when I'm not on a network. Thanks!
Post Reply