2

I've set up a Gentoo guest in virt-manager but I'm unable to SSH to it from host machine. I've read that using qemu I need to do some port forwarding to be able to access ports in guest machine. I couldn't find any option for this in virt-manager. How is it possible to do this?

I'm using Virt Manager 1.3.2 on Ubuntu 16.10.

1

My understanding was the opposite. If the network device of a libvirt VM is configured to connect to virbr0, you should be able to access it from the host machine.

The other option for the network device, where this doesn't work, is called "user networking". If that is not your problem, you will have to provide more information.

http://xkahn.zoned.net/blog/2013/11/26/networking-and-gnome-boxes

Arch suggest the virtual switch^Wbridge vibr0 is part of the default configuration of the libvirt daemon, so you just need to make sure the VM is configured to use it. wiki.archlinux.org/index.php/Libvirt#Networks

They link to jamielinux.com/docs/libvirt-networking-handbook - for virbr0 see https://jamielinux.com/docs/libvirt-networking-handbook/nat-based-network.html

0

Just to have this documented somewhere on the net:

I managed to do this some two years later by manually adding the relevant qemu arguments to the kvm XML file (which holds the config for all the fancy virtualisation foo behind the scenes).

Here's the steps I performed to grant port forwarding to a user network, in my case fowarding the host's port 22222 to the guest's port 22:

My emulated machine will be called ubuntu18.04 here.

  1. Open xml config for editing via virsh

    $ virsh -c qemu:///session edit ubuntu18.04
    
  2. Find and removet the configuration for the "user"-type interface which may look somehow like this:

    <interface type='user'>
      <mac address='52:54:00:52:35:ff'/>
      <model type='rtl8139'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
  1. Add the qemu namespace to the (root) domain tag:
   <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
  1. Manually add the now missing interface configuration as qemu arguments somewhere inside the domain tag (e.g as last child of ):
    <qemu:commandline>
      <qemu:arg value='-netdev'/>
      <qemu:arg value='user,id=mynet.0,net=10.0.10.0/24,hostfwd=tcp::22222-:22'/>
      <qemu:arg value='-device'/>
      <qemu:arg value='rtl8139,netdev=mynet.0'/>
    </qemu:commandline>
  1. Save the config and fire up/reboot the VM.

  2. ssh away:

    ssh myusername@localhost -p 22222
    
New contributor
quickida is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.