Ubuntu 64 上的 VirtualBox NAT 端口转发?

Gre*_*tes 5 networking virtualbox virtualization nat ubuntu

我有一个 Ubuntu 9.04 桌面 64 位来宾操作系统,它运行在 Ubuntu 9.04 桌面 64 位主机操作系统(是的,相同的操作系统)上。我想在来宾上运行一个 Web 服务器,并使其可通过主机上的 NAT 访问。

我(认为我)遵循了 VirtualBox 端口转发说明,但是在我进行配置后来宾/VM 不会启动。

这是我运行的配置:

VBoxManage setextradata "<Guest Name>" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/Protocol" TCP
VBoxManage setextradata "<Guest Name>" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/GuestPort" 80
VBoxManage setextradata "<Guest Name>" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort" 8080
Run Code Online (Sandbox Code Playgroud)

<Guest Name>来宾 VM 映像的名称在哪里。

错误如下所示:

在此处输入图片说明

无论我是在 VM 运行时运行配置还是未运行,都会发生相同的错误。

来宾添加已安装。

如何正确配置NAT端口转发?是什么导致了这个错误?

小智 5

使用命令获取您为此 WM 所做的所有参数:

VBoxManage.exe getextradata "Name_of_VM" enumerate
Run Code Online (Sandbox Code Playgroud)

您应该会看到传输到 VM 的所有值。

Key: GUI/SaveMountedAtRuntime, Value: yes
Key: GUI/ShowMiniToolBar, Value: yes
Key: GUI/MiniToolBarAlignment, Value: bottom
Key: GUI/LastCloseAction, Value: save
Key: GUI/LastWindowPostion, Value: 345,133,640,522
Key: GUI/Fullscreen, Value: off
Key: GUI/Seamless, Value: off
Key: GUI/AutoresizeGuest, Value: on
Key: GUI/MiniToolBarAutoHide, Value: on
Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort, Value: 22
Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort, Value: 22
Run Code Online (Sandbox Code Playgroud)

通过复制删除所有以 VBoXInternal 开头的 ligne 并将该行粘贴到这样的命令

VBoxManage.exe setextradata "Name_of_VM" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort"
Run Code Online (Sandbox Code Playgroud)

到最后没有任何价值。最后你应该再次枚举并且看不到更多的 VBoxInternal 行。

现在您可以再次创建 NAT 规则,为规则命名不同的名称。

Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort, Value: 2222
Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort, Value: 22
Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol, Value: TCP
Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/Protocol, Value: TCP
Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/GuestPort, Value: 80
Key: VBoxInternal/Devices/pcnet/0/LUN#0/Config/guesthttp/HostPort, Value: 8080
Run Code Online (Sandbox Code Playgroud)

在 linux 下你应该提醒 PORTS <1024 不应该被重定向。对guestsh 使用2222,对guesthttp 使用8080(示例)为了便于使用,我个人在WINDOWS 下使用<1014 端口。

希望这对你有帮助。

(对不起英语!我是法国人:P)

雅克·冈谢里安