Skip to content

Instantly share code, notes, and snippets.

@fairchild
Forked from avdi/vboxfwd
Created March 2, 2010 05:35
Show Gist options
  • Save fairchild/319170 to your computer and use it in GitHub Desktop.
Save fairchild/319170 to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ $# != 5 ]; then
echo "Utility for setting up NAT forwarding to VBox guests"
echo "Usage: $0 GUEST SERVICE PROTOCOL GUESTPORT HOSTPORT"
echo "E.g. $0 \"Linux Guest\" guestssh TCP 22 2222"
echo "NOTE: Port forwarding will only affect stopped VMs"
exit 1
fi
guest=$1
service=$2
protocol=$3
guestport=$4
hostport=$5
flags="-nologo"
VBoxManage $flags setextradata "$guest" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/$service/Protocol" $protocol
VBoxManage $flags setextradata "$guest" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/$service/GuestPort" $guestport
VBoxManage $flags setextradata "$guest" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/$service/HostPort" $hostport
#!/bin/sh
if [ $# != 2 ]; then
echo "Utility for tearing down NAT forwarding to VBox guests"
echo "Usage: $0 GUEST SERVICE"
echo "E.g. $0 \"Linux Guest\" guestssh"
echo "NOTE: Port forwarding will only affect stopped VMs"
exit 1
fi
guest=$1
service=$2
flags="-nologo"
VBoxManage $flags setextradata "$guest" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/$service/Protocol"
VBoxManage $flags setextradata "$guest" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/$service/GuestPort"
VBoxManage $flags setextradata "$guest" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/$service/HostPort"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment