Virtualization

Run virtual machines at near-native speeds and manage them at ease

Mapping a virtualized guest port to a host port

  1. Download the Fedora Workstation ISO file from website and store it in a reference directory cdromimg.
    https://getfedora.org
    
  2. Start a virtual machine for mapping a virtualized guest port to a host port for the live ISO and there is no need for a virtual disk image here.
    $ qemu-system-x86_64 \
        -boot menu=on \
        -m 4096 \
        -cpu max \
        -smp 4 \
        -cdrom cdromimg/<Fedora-Workstation-Live-x86_64-xx-y.z.iso> \
        -accel kvm \
        -net nic \
        -net user,hostfwd=tcp::2323-:22
    
  3. Wait for the virtual machine to boot up.
    01
  4. In a new terminal session on the guest, execute the following command to the enable the OpenSSH service.
    $ sudo systemctl enable --now sshd.service
    

    02

  5. Now change the password of the current user by executing the following command in the terminal session on the guest.
    $ passwd
    

    03

  6. In a new terminal session on the host, execute the following command to connect to the guest using SSH.
    $ ssh liveuser@localhost -p 2323
    

    04
    OR
    In a new terminal session on a device connected to the same network, execute the following command to connect to the guest using SSH.

    $ ssh liveuser@<ip-address-of-the-host-device> -p 2323
    

    05

  7. Execute the following command in to logout of the session.
    $ logout
    
  8. This was an example of mapping port 22 of the virtualized guest with port 2323 of the host with TCP for the purposes of SSH and this can be reused with slight changes to accommodate other use-cases.

Authors: Akashdeep Dhar, Jarek Prokop, Nick Dirschel