Configure port forwarding in VirtualBox

You'll not be able to directly login your guest virtual machine in Oracle's Virtualbox via SSH or RDP if it's under NAT network. You'll have to configure port forwarding to access your guest VM in Virtualbox 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. Fill in the fields accordingly.

    In this example, port 2202 in the host machine will forward to port 22 of the guest machine whereby is the default IP for guest VM under NAT network.

    Leaving the Host IP field blank will default to and Guest IP defaults to whatever the IP address is assigned to the guest VM.

  9. Test the forwarding rule.
    user@host:~ $ ssh -p2222 user@
    Warning: Permanently added '[]:2222' (ECDSA) to the list of known hosts.
    user@'s password:
    Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-20-generic x86_64)
     * Documentation:
     * Management:
     * Support:
      System information as of Wed Sep  5 16:52:59 +08 2018
      System load:  0.0               Processes:             91
      Usage of /:   18.8% of 8.80GB   Users logged in:       1
      Memory usage: 6%                IP address for enp0s3:
      Swap usage:   0%
    138 packages can be updated.
    72 updates are security updates.
    Last login: Wed Sep  5 16:47:16 2018 from
    To run a command as administrator (user "root"), use "sudo <command>".
    See "man sudo_root" for details.

    SSH is used to test the forwarding rule as SSH is listening on port 22 of the guest VM.