1

What I want:

I want a virtual machine guest running Ubuntu (on VirtualBox) for various web development test servers (running on different ports, e.g. Grunt.js is running on port 9000).

  • I want to test web applications running on these servers a) from within the guest b) from within the host (running Windows 7, btw), c) from other devices in the same network, connected via WiFi (e.g., mobile devices)

  • I want to be able to access the Internet from within the guest

I was first running a solution where I had both a NAT and a Host-only adapter configured in VirtualBox, which was fine for accessing the guest from the host and for accessing the Internet from within the guest.

Now that I want other devices to be able to access the virtual machine, this solution doesn't work anymore. I was able to do this years ago with a bridged network adapter, but that doesn't seem to work here, as I am in a corporate network.

What I did: So I set up a bridged network adapter with default settings in VirtualBox. When firing up the VM, I first saw that I don't have Internet access, and running ifconfig gives:

eth0      Link encap:Ethernet  HWaddr 08:00:27:d1:1f:98  
          inet6 addr: fe80::a00:27ff:fed1:1f98/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:139 errors:0 dropped:0 overruns:0 frame:0
          TX packets:658 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:11274 (11.2 KB)  TX bytes:140266 (140.2 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1728 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1728 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1001564 (1.0 MB)  TX bytes:1001564 (1.0 MB)

As you can see, no ipv4 is available, and I cannot ping or request anything from outside the guest. I am not fully sure whether its because something is misconfigured or whether its because the corporate network doesn't allow such things - I don't get any help from the IT department either...

EDIT: I found out that the bridged connection works when using another network, not the corporate one. I can also access the guest server from other devices.

How can I further debug this? And what could be the reason for such a behavior?

  • If, bridged networking isn't working you should speak with your corp helpdesk/IT dept. The should have the tools to help diagnose and fix this – Zoredache Mar 8 '14 at 2:15
1

Sadly, I'm not familiar enough with IPv6 to tell if your VM is picking up it's own IP or not, so I'll just say that the way a bridged connection works is the VM requests it's own IP, essentially making it so that your physical machine has 2 IPs on the network. If the corporate network has disabled DHCP like they most often do, or if they have restricted IPs in another way, you will have to get the VM it's own IP to function in the way you are looking for.

That being said, it is possible to set up "port forwarding" for the NAT network mode in VirtualBox. This way, when your physical machine is hit with a request at the port you specify, your machine passes it on through to your VM.

As the virtual machine is connected to a private network internal to VirtualBox and invisible to the host, network services on the guest are not accessible to the host machine or to other computers on the same network. However, like a physical router, VirtualBox can make selected services available to the world outside the guest through port forwarding. This means that VirtualBox listens to certain ports on the host and resends all packets which arrive there to the guest, on the same or a different port.

If you wish to get into more detail, that is from the "Network Address Translation (NAT)" section under "Virtual networking" in the VirtualBox Help file. There is a nice little GUI to help you with this under the advanced networking settings for your VM.

VirtualBox NAT Port Forwarding Location

  • 1
    Good idea, thank you. Haven't tested it in my corporate network yet, but it works at home. Is there any disadvantage in using this over bridged connection? – wnstnsmth Mar 7 '14 at 20:25
  • The only real disadvantage I can think of is having to watch out for port conflicts when using the NAT mode. If you got something on port 22 on your machine, might be some issues if you try to forward that to the VM. When you bridge, the VM gets it's own IP and therefore it's own set of ports. – Aeo Mar 7 '14 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.