OnlineWebTools

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;

  1. Go to Virtualbox‘s main interface and make sure the virtual machine that you want to configure is powered off.
  2. Select your virtual machine and click Settings icon on the top toolbar. Alternatively, right click on the virtual machine and click Settings.
  3. Click on the Network tab in Settings main interface.
  4. Look for and click on Advanced text at the bottom of the window.
  5. Click on Port Forwarding button.
  6. Click on the + icon on the upper right to add new port forwarding rule in Port Forwarding‘s main interface.
  7. Some of the fields are automatically filled up as the followings.
  8. Test the forwarding rule.
    $ ssh -p2022  user@127.0.0.1
    Warning: Permanently added '[127.0.0.1]:2022' (ECDSA) to the list of known hosts.
    user@127.0.0.1'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 as SSH is listening on port 22 of the guest VM.

Exit mobile version