2

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?

2 Answers 2

3
  • 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

1

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?

1
  • sorry, how can I check that? Mar 4, 2011 at 13:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .