Linux – Unable to ping guest from host and vise versa in Oracle Virtual Box


This is my Oracle Virtual Box Version 4.2.18 r88780

Details of my host machine

Operating System : Scientific Linux 6.4

I am using static ip

root@localhost ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:1E:EC:95:18:66  
          inet addr:  Bcast:  Mask:
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

Details of my guest machine

Operating System: CentOS 6.4

eth0      Link encap:Ethernet  HWaddr 08:00:27:6D:C3:A6  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::a00:27ff:fe6d:c3a6/64 Scope:Link
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:29 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:360 (360.0 b)  TX bytes:1746 (1.7 KiB)

This is my Virtual Box Network Setting

enter image description here

This is the ping output

[root@localhost ~]# ping 
PING ( 56(84) bytes of data.
From icmp_seq=1 Destination Host Unreachable
From icmp_seq=2 Destination Host Unreachable
From icmp_seq=3 Destination Host Unreachable
--- ping statistics ---
6 packets transmitted, 0 received, +3 errors, 100% packet loss, time 5640ms
pipe 3

I tried flushing iptables also still not working, loopback is working.

Best Answer

In most cases the easiest setup is to use NAT and define port forwarding as needed.

For example, a simple Port Forwarding setup allowing connection to the VM from the host through shh on localhost:10022, and to the webserver on localhost:8080would be:

(Name - Protocol - Host IP : Host Port - Guest IP : Guest Port)
SSH - TCP - : 10022 -*) : 22
www - TCP - : 8080 -*) : 80

(*) virtual IP returned by a ifconfig from the VM, most probably different for you.

Should you have special requirements preventing NAT from working, please give some details about what you want to achieve.