My host is Ubuntu 12.04 and guest is a Debian squeeze (LAMP server). I want to allow the host to connect the guest. and allow the guest to connect the internet. The guest should not be enabled from outside. That's the reason why I don't use network-bridge. I want to setup a static IP for the host. I followed this tutorial.

So I took these steps but I can not connect via ssh from host to guest. I cannot call the server via browser. ping works however!

I've created a virtual host-only network adapter (vboxnet0) with following settings:


ifconfig in Ubuntu host shows this:

eth0      Link encap:Ethernet  Hardware Adresse XX:XX:XX:XX:XX:XX  
          inet Adresse:  Bcast:  Maske:
          inet6-Adresse: XXXX:XXX:XXXX:XXXX:X:X/XX Gültigkeitsbereich:Global

vboxnet0  Link encap:Ethernet  Hardware Adresse XX:XX:XX:XX:XX:XX  
          inet Adresse:  Bcast:  Maske:
          inet6-Adresse: XXXX:XXX:XXXX:XXXX:X:X/XX Gültigkeitsbereich:Verbindung
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10069 errors:0 dropped:0 overruns:0 carrier:0
          Kollisionen:0 Sendewarteschlangenlänge:1000 
          RX-Bytes:0 (0.0 B)  TX-Bytes:1539501 (1.5 MB)

On the Debian squeeze guest, the /etc/network/interfaces looks like this:

 # The host-only network interface
   auto eth1
   iface eth1 inet static

I've already tried to change eth1 to eth0 without a result.

In VirtualBox settings the promiscuous-mode allows VMs and Host to connect.

I have reached the limits of my knowledge.

the output of:

netstat --inet --inet6 -ln | grep :22

is nothing.

the output of:

sudo iptables -L INPUT -nv


 Chain INPUT (policy ACCEPT 166 packets, 30786 bytes)
  pkts bytes target     prot opt in     out     source               destination 
  • What is the output of netstat --inet --inet6 -ln | grep :22 and iptables -L INPUT -nv? – Hauke Laging May 5 '13 at 2:23
  • Well your problem has nothing to do with linux, you should create a private network between your host and your virtual machine through the VB user interface and add a NAT interface to your Virtual machine. you will have internet trhough natted interface and private acces to it with the private network adater christophermaier.name/blog/2010/09/01/… – Kiwy Jan 6 '14 at 10:32

You should not use the same IP address in your guest (like the one on the host interface). If you setup vboxnet0 on the host to IP address, then in your guest you should use for example. The gateway for your guest should be the host's IP (in your case

This should do the host<->guest connection. If you want your guest to have internet too, then you should masquerade it's IP (or the network) on your host.

iptables -t nat -I POSTROUTING -s -j MASQUERADE
sysctl net.ipv4.ip_forward=1

you may need to set the default policy to forward or to enable your masqueraded network specifically:

iptables -t nat -P POSTROUTING ACCEPT

note: You can execute these lines with root, to enable the internet access to your guest. But, these lines should probably go to your firewall configuration of yout host. (i.e. ufw). The sysctl configuration file is: /etc/sysctl.conf, you can set ip_forward there, if you want it always enabled.

| improve this answer | |

Your Answer

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