-
-
Save fairchild/319170 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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