話說VirtualBox功能完善,該有的都有,但是有些功能沒有做視窗的操作介面,還是要靠指令,設定Port Forwarding即是一個例子,需用VBoxManage的指令來設定。
假設Guest VM提供SSH的服務(Port:22),跟主機的Port:2222相對應,以下就是設定Port Forwarding的指令
VBoxManage setextradata "Linux Guest"其中Linux Guest是Guest VM的名稱,guestssh是任意的取的名稱。
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata "Linux Guest"
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
VBoxManage setextradata "Linux Guest"
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222
PS1: 不管是windows跟linux版的VirtualBox,指令設定及參數值都是一樣
PS2: 指令下完後,設定不會馬上生效,必需關掉Guest VM後再開,請注意不是重起喔!是turn off VM之後再start VM。
PS3: 如果是要取消設定,一樣是下這3行指令,但把最後的參數值拿掉(TCP﹑22﹑2222)即可。
2 則留言:
I am using VirtualBox 2.1.0 but port forwarding is not working with a host OS of Vista.
Does Vista as host OS need some tricks?
I don't use Vista, so I have no idea about that. However, it does not mention the setting among different host OSs in its manual.
張貼留言