How to access guest VM in Virtualbox via port forwarding
You’ll not be able to directly access your guest virtual machine in Virtualbox
via SSH
or RDP
if it’s under NAT
network. For this you’ll have to configure port forwarding as detailed below;
-
Test the forwarding rule.
$ ssh -p2022 [email protected] Warning: Permanently added '[127.0.0.1]:2022' (ECDSA) to the list of known hosts. [email protected]'s password: Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-83-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage 0 packages can be updated. 0 updates are security updates. Last login: Fri Jul 7 09:29:30 2017 user@ubuntu:~$
SSH
is used to test the forwarding rule asSSH
is listening on port22
of the guest VM.