visualbox nat方式联网时ssh无法访问虚拟机的解决办法

来源:互联网 发布:三亚婚纱摄影 知乎 编辑:程序博客网 时间:2024/05/21 10:21

In NAT mode (the default one), virtualbox does not give you the possibility to directly connect to your guest os.

Running a server as a guest in a VirtualBox virtual machine isn’t much good when you can’t network with the guest OS from your host machine. Instead of setting up host interface networking, you can simply port forward though VirtualBox’s NAT. Once port forwarding is set up, any computer on your network will be able to network with your guest OS though forwarded ports on your host.

所以,如果虚拟机利用NAT联网时,如果想利用putty或者ssh访问虚拟机时,就必须设置好端口转发。

可以通过命令方式实现端口转发,也可以通过visual box的界面直接进行设置:





上面这样设置的意思就是:ssh访问host(即localhost)时:ssh localhost,自动会转到虚拟机上去。



这样就能访问guestos了。






原创粉丝点击