Skip to content

Instantly share code, notes, and snippets.

@baflo
Last active December 7, 2018 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baflo/91b086d677300194da00f6e6203e2202 to your computer and use it in GitHub Desktop.
Save baflo/91b086d677300194da00f6e6203e2202 to your computer and use it in GitHub Desktop.
Set port forwarding for running vbox
@echo off
setlocal EnableDelayedExpansion
setlocal EnableExtensions
if "%~2"=="add" (
if "%~1"=="" goto :usage
if "%~3"=="" goto :usage
"%programfiles%\Oracle\VirtualBox\VBoxManage.exe" controlvm "%~1" natpf1 "%~3"
goto :EOF
)
if "%~2"=="rm" (
if "%~1"=="" goto :usage
if "%~3"=="" goto :usage
"%programfiles%\Oracle\VirtualBox\VBoxManage.exe" controlvm "%~1" natpf1 delete "%~3"
goto :EOF
)
:usage
echo Usage:
echo vboxvm-natpf ^<vmname^> ^(rm ^<pfname^> ^| add "<pfdef>" ^)
echo.
echo Format of ^<pfdef^> ^(all commas must appear^):
echo "[<rulename>],tcp|udp,[<hostip>],<hostport>,[<guestip>],<guestport>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment