Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've setup a Virtualbox Ubuntu 12.04 server using Vagrant. I can ssh to it and even ping my desktop from it. What doesn't work is to ping the guest OS from my desktop.

I've tried to flush the iptables and disable my firewall (ufw disable).

The guest OS is configured as NAT (10.0.2.15). And my desktop as bridged (192.168.0.23).

I also tried configuring the guest OS to have bridged networking as well. But then I could not start the Django development server. Got an error about it not being possible to use that ip.

What am I missing here?

vagrant@precise32:~ifconfig -a     
eth0      Link encap:Ethernet  HWaddr 08:00:27:12:96:98  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe12:9698/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:193157 errors:0 dropped:0 overruns:0 frame:0
          TX packets:102002 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:170818571 (170.8 MB)  TX bytes:8109666 (8.1 MB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:a1:d9:5f  
          inet6 addr: fe80::a00:27ff:fea1:d95f/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:795 errors:0 dropped:0 overruns:0 frame:0
          TX packets:115 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:60352 (60.3 KB)  TX bytes:30546 (30.5 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:16436  Metric:1
          RX packets:1226 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1226 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:361973 (361.9 KB)  TX bytes:361973 (361.9 KB)


vagrant@precise32:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
auto eth1
iface eth1 inet dhcp
    post-up route del default dev $IFACE
#VAGRANT-END
share|improve this question
    
Looks like the vagrant box has 2 network interfaces. You can SSH to it because it is via NAT port forwarding, in other words, you are connecting to 127.0.0.1 port 2222 (mapping to guest 22). Make sure the vagrant VM has a route to the host. –  Terry Wang Aug 20 '13 at 0:52
add comment

1 Answer

Looks like the vagrant box has 2 network interfaces: eth0 and eth1.

NOTE: The eth1 has a post-up action to delete the default route, which means it cannot reach the outside world. You may have set up private only network.

You can SSH to it because it is via NAT port forwarding, in other words, you are connecting to 127.0.0.1 port 2222 (mapping to guest 22).

In theory, to be able to ping the guest 10.0.2.15/24 in 10.0.2.0/24 network, the host MUST have a route to the network.

In your case, this is a VirtualBox VM hiding behind the virtual NAT router, and what you see (host cannot ping the virtual machine) that's how NAT works. The host won't be able to reach the host behind NAT unless port forwarding rules for (TCP/UDP) are configured. Unfortunately ping replies on ICMP, no way. I am not sure if you can figure out a route that doesn't break your existing networking.

So to sum up, you would like to ping the guest VM from host, switch to bridged networking or enable a secondary network adapter as bridged so that it will be reachable from host (as the VM will have a IP address in the same subnet).

share|improve this answer
add comment

Your Answer

 
discard

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

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