Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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 
share|improve this question

migrated from May 4 '13 at 10:11

This question came from our site for professional and enthusiast programmers.

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… – Kiwy Jan 6 '14 at 10:32

1 Answer 1

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.