Feb 6, 2009

Host Interface Networking With Virtualbox

-:This is how easy it is to setup networking with Virtualbox:-
I have done it on my Ubuntu8.10 & am pretty sure that it will work with other distros also. You may need to change the commands according the basic settings of your distro, for example I am gaining root preveleges & you may use sudo and in my case the network card it eth1 you may eth0.

apt-get install uml_utilities

chowm root.vboxusers /dev/net/tun

chmod g+rw /dev/net/tun

tunctl -u $USER

sysctl net.ipv4.ip_forward=1

sysctl net.ipv4.conf.wlan0.proxy_arp=1


sysctl net.ipv4.conf.tap0.proxy_arp=1


ifconfig tap0 up

route add -host 192.168.1.200 dev tap0

Check the screenshot of the guest os network setting in virtualbox below:



Also you may copy the following script to /etc/init.d/tap, use it as other init scripts with /etc/init.d/tap start and /etc/init.d/stop:

#!/bin/bash
# tap-setup.sh

# Change username accordingly
USER="username_here"

tap_up(){
tunctl -u $USER
sysctl net.ipv4.ip_forward=1
sysctl net.ipv4.conf.wlan0.proxy_arp=1
sysctl net.ipv4.conf.tap0.proxy_arp=1
ip link set tap0 up
route add -host 192.168.1.200 dev tap0
}

tap_down(){
sysctl net.ipv4.ip_forward=0
sysctl net.ipv4.conf.wlan0.proxy_arp=0
sysctl net.ipv4.conf.tap0.proxy_arp=0
tunctl -d tap0
}

if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
else

case "$1" in

start)
tap_up
;;
stop)
tap_down
;;
*)
echo "Usage: $0 {start|stop}"
;;
esac

fi

exit 0
# end of script








No comments:

Post a Comment