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 can't ping my Ubuntu on VirtualBox (within another Ubuntu).

I had set my ip using:

# ifconfig eth0 192.168.0.2 netmask 255.255.255.0 up

but the ping still fails. What's different when you're in the VirtualBox?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted
  • First you must install the following programs:

sudo apt-get install uml-utilities bridge-utils

  • then you have to add something to the kernel:

sudo modprobe tun

  • Now, Here is a script that allows a guest virtual machine to connect to the main host and also have internet on both machines, you have to make a small adjustment to changing the USER variable for your user and ready, I save the script as vb:

permission first :

sudo chmod +x vb

then to start :

sudo ./vb start

if we do not need it anymore

sudo ./vb stop

  • create the virtual machine and configure it in the choice of network adapter bridge and interface vth0 and you are ready.,

Here the Script :

#!/bin/bash

if [ -z $1 ]; then
echo "Usage: $0 [start|stop]"
exit 1
fi

#Check root

USER=$(id -u)

if [ "$USER" -ne "0" ]; then
echo "Must be root"
exit 1
fi

USER=your user
TAP=vth0
BR=br0
ETH=eth0

function doStart {
#Create the bridge
brctl addbr $BR
ifconfig $ETH 0.0.0.0 promisc
brctl addif $BR $ETH
dhclient $BR

tunctl -t $TAP -u $USER
brctl addif $BR $TAP
ifconfig $TAP up

echo "$TAP ready"
}

function doStop {
ifconfig $BR down
ifconfig $TAP down
tunctl -d $TAP
brctl delbr $BR
dhclient $ETH

echo "Cleaned"
}

case $1 in
start)
doStart
;;

stop)
doStop
;;

*)
echo "Usage: $0 [start|stop]"
;;
esac

exit 0

Step :

  • Execute the script
  • create your virtual machine or modify, in the machine configuration select NETWORK

enter image description here

  • then select BRIDGE ADAPTER and interface VTH0

enter image description here

share|improve this answer
add comment

I know that in vmware you have the option of bridging the connection from the hardware ethernet to the virtualized ethernet device. Are the connections bridged in VirtualBox?

share|improve this answer
    
sorry, how can I check that? –  Tom Brito Mar 4 '11 at 13:00
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.