I have guest Ubuntu operating systems installed in Oracle VirtualBox. I'm using Ubuntu 10.04 as the host(base) operating system with static public IP addresses.

I can access the Internet on guest(VirtualBox) OS only if I select the NAT as network mode in VirtualBox settings and this is fine, but host(base) to guest(VirtualBox) networking is not working.

I want to connect my guest OS from host via ssh.

I need a step by step guide.

  • Selecting Bridged adapter did the work
    – user53864
    Feb 11, 2013 at 3:58

4 Answers 4


I wrote a HOWTO for Linux Journal regarding port forwarding within NAT in VirtualBox here: http://www.linuxjournal.com/content/tech-tip-port-forwarding-virtualbox-vboxmanage

Use the VBoxManage utility to forward an unused local port (like 2222) to port 22 of the virtual machine (assuming that you are using the default port on the VM), which will easily allow you to SSH into your virtual machine.


When you use NAT for your Guest instances, VirtualBox creates a separate "subnet" (10.x.x.x) within which the Guest instances operate. In order to access these instances, you need to set up Static Routes on the Host system. There are plenty of links / guides out there where people have done this.

Alternatively, you could use Bridged Networking instead of NAT. Bridged Networking will put the Guest instances in the same network as your Host operating system, thereby giving you direct access.

  • Maybe a link to one of the guides you've seen that is most clear on the topic? I've looked (not recently), but never found anything really great.
    – Nate
    Sep 17, 2010 at 15:36
  • No, I could only access the internet if I select NAT mode. If I select bridge, host to guest networking is possible but I couldn't access internet.
    – user53864
    Sep 17, 2010 at 16:26

The reason is that in NAT mode VirtualBox effectively provides routing of Internet traffic to and from the virtual machine, whereas in bridged mode you have to do this yourself. In other words, you need to set up your host computer as an Internet gateway (with forwarding and SNAT or masquerading). In bridged mode your guest behaves as if it were a completely separate computer on a LAN behind the firewall (or a completely separate computer on the internet, but that will require a separate static IP address), which is sort of the whole point of running a virtual machine.

Since you probably only have one static public IP address, you need to bind another (internal) IP address to the host OS, either on the same interface or on a different one, and then either allow the guest to acquire an IP address on the same internal subnet from a DHCP server or configure it statically that way. Then you set up iptables on the host to do forwarding from the external IP to the internal LAN, plus the relevant rules for SNAT/MASQUERADE, and all should be fine.

  • Could you instruct me how to do forwarding(SNAT or masquerading).
    – user53864
    Sep 19, 2010 at 13:38
  • How much do you know about iptables?
    – wolfgangsz
    Sep 19, 2010 at 16:48

NAT with port forwarding was not an option for me. I wanted VirtualBox to work like VMWare Workstation's NAT, where I can ssh/browse from my host to my guest using a consistent IP, and the guest can still get out to the internet. The way to do this is to configure your guest with two network adapters, one NAT and one Host-Only (vbox0). Full instructions can be found here:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .