#!/bin/sh
#Created by agentc0re, agentc0reatgmaildotcom
#This script was created to start and stop a vboxtunctl interface and
#assign it an ip address.
#Define bridge interface, ip and your username.
#Besure to change these settings to fit your needs
#The ip address should be on the same subnet as your pc.
br="br0"
br_ip="10.1.1.5"
br_netmask="255.255.255.0"
user="agentc0re"
interface=""
start_network(){
# Create an newTAP interface for the user ?vbox? and remember its name.
interface="$(VBoxTunctl -b -u $user 2> /dev/null)"
# If for some reason the interface could not be created, return 1 to
# tell this to VirtualBox.
if [ -z "$interface" ]; then
exit 1
fi
# Write the name of the interface to the standard output.
echo "$interface Is your tap interface"
# Bring up the interface.
/sbin/ifconfig $interface up
# Create a bridge and then add the tap interface to the bridge.
/sbin/brctl addbr $br
/sbin/brctl addif $br $interface
/sbin/ifconfig $br $br_ip netmask $br_netmask
}
stop_network(){
# Find out the tap interface
if ifconfig -a | grep tap0
then interface=tap0
else
exit 1
fi
echo "Removing $interface"
# Remove the interface from the bridge. The second script parameter is
# the interface name.
/sbin/brctl delif br0 $interface
# And use VBoxTunctl to remove the interface.
VBoxTunctl -d $interface
# Remove the bridged interface
/sbin/ifconfig $br down
/sbin/brctl delbr $br
}
start() {
start_network
}
stop() {
stop_network
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo "Usage: `basename $0` {start|stop}"
exit 1
esac
exit