No internet qemu guest os

I am trying to setup a windows guest VM with Qemu. I managed to do so by following the article QEMU on the Arch Linux wiki and I also referred this article Windows Guest VM using Qemu , the setup and installation were smooth with no issues, but VM does not have internet. The guest sees the network adapter and driver but reports no internet.

what could be causing this? how do I go about troubleshooting this?

My system info is as follows

      ~  inxi -F                                       ✔  03:18:46 PM   
System:
  Host: jose Kernel: 5.4.134-1-MANJARO x86_64 bits: 64 Desktop: GNOME 40.3 
  Distro: Manjaro Linux 
Machine:
  Type: Laptop System: Micro-Star product: GS65 Stealth 8SF v: REV:1.0 
  serial: <superuser required> 
  Mobo: Micro-Star model: MS-16Q4 v: REV:1.0 serial: <superuser required> 
  UEFI: American Megatrends v: E16Q4IMS.116 date: 10/07/2019 
Battery:
  ID-1: BAT1 charge: 40.8 Wh (73.9%) condition: 55.2/80.3 Wh (68.7%) 
  volts: 15.5 min: 15.2 
CPU:
  Info: 6-Core model: Intel Core i7-8750H bits: 64 type: MT MCP cache: 
  L2: 9 MiB 
  Speed: 3294 MHz min/max: 800/4100 MHz Core speeds (MHz): 1: 3294 2: 3045 
  3: 1256 4: 2174 5: 3446 6: 2774 7: 3398 8: 3294 9: 2732 10: 2433 11: 2923 
  12: 2713 
Graphics:
  Device-1: Intel CoffeeLake-H GT2 [UHD Graphics 630] driver: i915 v: kernel 
  Device-2: NVIDIA TU106M [GeForce RTX 2070 Mobile] driver: nvidia 
  v: 470.57.02 
  Device-3: Acer HD Webcam type: USB driver: uvcvideo 
  Display: x11 server: X.Org 1.20.11 driver: loaded: modesetting,nvidia 
  resolution: 1: 1920x1080~144Hz 2: 1920x1080~144Hz 
  OpenGL: renderer: NVIDIA GeForce RTX 2070 with Max-Q Design/PCIe/SSE2 
  v: 4.6.0 NVIDIA 470.57.02 
Audio:
  Device-1: Intel Cannon Lake PCH cAVS driver: snd_hda_intel 
  Sound Server-1: ALSA v: k5.4.134-1-MANJARO running: yes 
  Sound Server-2: PulseAudio v: 14.2 running: yes 
Network:
  Device-1: Intel Cannon Lake PCH CNVi WiFi driver: iwlwifi 
  IF: wlo1 state: up mac: 04:ea:56:b6:31:d1 
  Device-2: Qualcomm Atheros Killer E2500 Gigabit Ethernet driver: alx 
  IF: enp61s0 state: down mac: 00:d8:61:06:44:e1 
  IF-ID-1: docker0 state: down mac: 02:42:41:66:b4:51 
  IF-ID-2: virbr0 state: down mac: 52:54:00:78:1d:97 
Bluetooth:
  Device-1: Intel Bluetooth 9460/9560 Jefferson Peak (JfP) type: USB 
  driver: btusb 
  Report: rfkill ID: hci0 rfk-id: 1 state: down bt-service: enabled,running 
  rfk-block: hardware: no software: yes address: see --recommends 
Drives:
  Local Storage: total: 1.38 TiB used: 409.17 GiB (29.1%) 
  ID-1: /dev/nvme0n1 vendor: Kingston model: RBUSNS8154P3512GJ 
  size: 476.94 GiB 
  ID-2: /dev/nvme1n1 vendor: Samsung model: SSD 970 EVO Plus 1TB 
  size: 931.51 GiB 
Partition:
  ID-1: / size: 816.43 GiB used: 409.15 GiB (50.1%) fs: ext4 
  dev: /dev/nvme1n1p3 
  ID-2: /boot/efi size: 296 MiB used: 26 MiB (8.8%) fs: vfat 
  dev: /dev/nvme0n1p1 
Swap:
  ID-1: swap-1 type: file size: 64 GiB used: 0 KiB (0.0%) file: /swapfile 
Sensors:
  System Temperatures: cpu: 60.0 C mobo: N/A gpu: nvidia temp: 58 C 
  Fan Speeds (RPM): N/A 
Info:
  Processes: 320 Uptime: 1h 19m Memory: 31.26 GiB used: 3.31 GiB (10.6%) 
  Shell: Zsh inxi: 3.3.06 

My configuration for the Windows Guest VM is as follows

<domain type="kvm">
  <name>win10</name>
  <uuid>d56389ef-8ad2-408d-b563-6f9506729433</uuid>
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://microsoft.com/win/10"/>
    </libosinfo:libosinfo>
  </metadata>
  <memory unit="KiB">4194304</memory>
  <currentMemory unit="KiB">4194304</currentMemory>
  <vcpu placement="static">4</vcpu>
  <os>
    <type arch="x86_64" machine="pc-q35-6.0">hvm</type>
    <boot dev="hd"/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state="on"/>
      <vapic state="on"/>
      <spinlocks state="on" retries="8191"/>
    </hyperv>
    <vmport state="off"/>
  </features>
  <cpu mode="host-model" check="partial"/>
  <clock offset="localtime">
    <timer name="rtc" tickpolicy="catchup"/>
    <timer name="pit" tickpolicy="delay"/>
    <timer name="hpet" present="no"/>
    <timer name="hypervclock" present="yes"/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled="no"/>
    <suspend-to-disk enabled="no"/>
  </pm>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type="file" device="disk">
      <driver name="qemu" type="qcow2" discard="unmap"/>
      <source file="/var/lib/libvirt/images/win10.qcow2"/>
      <target dev="vda" bus="virtio"/>
      <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="/home/jose/Downloads/Win10_21H1_EnglishInternational_x64.iso"/>
      <target dev="sdb" bus="sata"/>
      <readonly/>
      <address type="drive" controller="0" bus="0" target="0" unit="1"/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="/home/jose/Downloads/virtio-win-0.1.185.iso"/>
      <target dev="sdc" bus="sata"/>
      <readonly/>
      <address type="drive" controller="0" bus="0" target="0" unit="2"/>
    </disk>
    <controller type="usb" index="0" model="qemu-xhci" ports="15">
      <address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
    </controller>
    <controller type="sata" index="0">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x1f" function="0x2"/>
    </controller>
    <controller type="pci" index="0" model="pcie-root"/>
    <controller type="pci" index="1" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="1" port="0x10"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0" multifunction="on"/>
    </controller>
    <controller type="pci" index="2" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="2" port="0x11"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x1"/>
    </controller>
    <controller type="pci" index="3" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="3" port="0x12"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x2"/>
    </controller>
    <controller type="pci" index="4" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="4" port="0x13"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x3"/>
    </controller>
    <controller type="pci" index="5" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="5" port="0x14"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x4"/>
    </controller>
    <controller type="pci" index="6" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="6" port="0x15"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x5"/>
    </controller>
    <controller type="pci" index="7" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="7" port="0x16"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x6"/>
    </controller>
    <controller type="pci" index="8" model="pcie-to-pci-bridge">
      <model name="pcie-pci-bridge"/>
      <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
    </controller>
    <controller type="pci" index="9" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="9" port="0x17"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x7"/>
    </controller>
    <controller type="virtio-serial" index="0">
      <address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/>
    </controller>
    <interface type="network">
      <mac address="52:54:00:19:e3:55"/>
      <source network="default"/>
      <model type="virtio"/>
      <address type="pci" domain="0x0000" bus="0x02" slot="0x00" function="0x0"/>
    </interface>
    <serial type="pty">
      <target type="isa-serial" port="0">
        <model name="isa-serial"/>
      </target>
    </serial>
    <console type="pty">
      <target type="serial" port="0"/>
    </console>
    <channel type="spicevmc">
      <target type="virtio" name="com.redhat.spice.0"/>
      <address type="virtio-serial" controller="0" bus="0" port="1"/>
    </channel>
    <input type="tablet" bus="usb">
      <address type="usb" bus="0" port="1"/>
    </input>
    <input type="mouse" bus="ps2"/>
    <input type="keyboard" bus="ps2"/>
    <graphics type="spice" autoport="yes">
      <listen type="address"/>
      <image compression="off"/>
    </graphics>
    <sound model="ich9">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x1b" function="0x0"/>
    </sound>
    <audio id="1" type="spice"/>
    <video>
      <model type="qxl" ram="65536" vram="65536" vgamem="16384" heads="1" primary="yes"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0"/>
    </video>
    <redirdev bus="usb" type="spicevmc">
      <address type="usb" bus="0" port="2"/>
    </redirdev>
    <redirdev bus="usb" type="spicevmc">
      <address type="usb" bus="0" port="3"/>
    </redirdev>
    <watchdog model="i6300esb" action="reset">
      <address type="pci" domain="0x0000" bus="0x08" slot="0x01" function="0x0"/>
    </watchdog>
    <memballoon model="virtio">
      <address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/>
    </memballoon>
    <rng model="virtio">
      <backend model="random">/dev/urandom</backend>
      <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
    </rng>
  </devices>
</domain>

Any help would be much appreciated.

How did you set up your default network?

If you use libvirt with virsh check for example

virsh net-info default

and

virsh net-dumpxml default

https://wiki.archlinux.org/title/Libvirt#Networks

If you use plain Qemu, you need to set it up yourself. Check out
https://wiki.archlinux.org/title/QEMU#Networking

I used virt manager to do VM setup and during the setup process the virtual network interface was already present, I just changed the Device model to virtio. Beyond that I didn’t do anything.

I ran the commads you provided and both result in failed to get the network ‘default’

      ~  virsh net-info default                        ✔  06:51:33 PM   
error: failed to get network 'default'
error: Network not found: no network with matching name 'default'
      ~  virsh net-dumpxml default                 INT ✘  06:53:53 PM   
error: failed to get network 'default'
error: Network not found: no network with matching name 'default'

Does this mean I have to setup the network ?

Of course. In your screenshot, you see Network Source - Virtual network ‘default’ . It needs to configured correctly. It is part of the Host setup.

In Virtual Machine Manager it can be done via Edit → Connection details in the main overview window.

Thank you for clarifying that, it was my understanding that the initial setup wizard took care of that. I checked the Connection details option and I see there is already an IPv4 configuration.

<network>
  <name>default</name>
  <uuid>6115b620-438d-44ad-9215-ce3ca396a890</uuid>
  <forward mode="nat">
    <nat>
      <port start="1024" end="65535"/>
    </nat>
  </forward>
  <bridge name="virbr0" stp="on" delay="0"/>
  <mac address="52:54:00:78:1d:97"/>
  <ip address="192.168.122.1" netmask="255.255.255.0">
    <dhcp>
      <range start="192.168.122.2" end="192.168.122.254"/>
    </dhcp>
  </ip>
</network>

Is there something missing or is the configuration wrong ?

It does not state to which device. I usually add dev="myInternteDevice" (like dev="eth0"), but it seems it is not required.

The Kernel parameter net.ipv4.ip_forward should be set automatically. But you might want to check it

sysctl net.ipv4.ip_forward

If this looks ok, you need to go back to the VM, and do some Windows Networking troubleshooting.

If your laptop uses a wireless link to connect to the Internet, then a bridged network is rather challenging. The wireless standards don’t support bridging, there is a workaround but it’s rather difficult.

If your computer is connected to the router via a cable, then a network bridge works and provides the best performance. The network bridge should be setup on the host, for example by using NetworkManager.

Here is the xml configuration of a network bridge (part of the VM configuration):

<interface type="bridge">
  <mac address="52:54:00:e1:01:01"/>
  <source bridge="bridge0"/>
  <model type="virtio"/>
  <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
</interface>

If you have a wireless connection, use the default NAT network type offered by virt-manager.

When you configure the Windows guest, you need to have the driver ISO ready to install the virtio network driver. Did you install the driver under Windows?

Another thing you should change in your configuration is memballoon. Set it to “none”.

Bottom line: If you run your VM on a laptop (that uses wireless), DON’T use a network bridge. Instead, choose the standard NAT network. Also, don’t configure a bridge on the host. Make sure to install the virtio network driver under Windows.

(Unfortunately I use a bridge and can’t show examples of a NAT configuration.)

I tried adding the line dev=“wlo1”, since I am using wifi, the config looked like this afterward

<network>
  <name>default</name>
  <uuid>6115b620-438d-44ad-9215-ce3ca396a890</uuid>
  <forward mode="nat" dev"wlo1">
    <nat>
      <port start="1024" end="65535"/>
    </nat>
  </forward>
  <bridge name="virbr0" stp="on" delay="0"/>
  <mac address="52:54:00:78:1d:97"/>
  <ip address="192.168.122.1" netmask="255.255.255.0">
    <dhcp>
      <range start="192.168.122.2" end="192.168.122.254"/>
    </dhcp>
  </ip>
</network>

when I try to apply changes I get an error message

Error changing network settings: (network_definition):4: Specification mandates value for attribute dev
  <forward mode="nat" dev"wlo1">
-------------------------^

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/hostnets.py", line 333, in _net_apply
    net.define_xml(self._xmleditor.get_xml())
  File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 339, in define_xml
    self._redefine_xml_internal(origxml, newxml)
  File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 366, in _redefine_xml_internal
    self._define(newxml)
  File "/usr/share/virt-manager/virtManager/object/network.py", line 54, in _define
    return self.conn.define_network(xml)
  File "/usr/share/virt-manager/virtManager/connection.py", line 556, in define_network
    return self._backend.networkDefineXML(xml)
  File "/usr/lib/python3.9/site-packages/libvirt.py", line 4924, in networkDefineXML
    raise libvirtError('virNetworkDefineXML() failed')
libvirt.libvirtError: (network_definition):4: Specification mandates value for attribute dev
  <forward mode="nat" dev"wlo1">
-------------------------^

I tired checking and it returns the value 1

       ~  sysctl net.ipv4.ip_forward                                                                                                                          ✔  38s    10:12:30 PM   
net.ipv4.ip_forward = 1

as @xabbu @heiko_s mentioned I made sure to load drivers during guest os installation and I also installed the virtio guest drivers after install. I used the stable virtio-win ISO from this github page to load drivers during guest installation and virtio guest drivers after installation.

When I ipconfig -all in the guest os I get the following

You forget the equal sign.

You can see in the screen shot from the VM, that the DHCP worked and all IP address are correct assigned.

The next step would be to ping. Start with 192.168.122.1, then the IP of the host, the IP of your Router and some IPs form the internet.

After that would need to check DNS, use nslookup on the windows host.

Thank you, quite the embarrassing mistake (facepalm moment). I corrected it but still no internet.

I am able to ping 192.168.122.1

C:\Users\Jose>ping 192.168.122.1                                                                                                                                                                                                                Pinging 192.168.122.1 with 32 bytes of data:                                                                            
Reply from 192.168.122.1: bytes=32 time<1ms TTL=64                                                                      
Reply from 192.168.122.1: bytes=32 time<1ms TTL=64                                                                      
Reply from 192.168.122.1: bytes=32 time<1ms TTL=64                                                                      
Reply from 192.168.122.1: bytes=32 time<1ms TTL=64                                                                                                                                                                                              Ping statistics for 192.168.122.1:                                                                                         
 Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),                                                                
Approximate round trip times in milli-seconds:                                                                             
 Minimum = 0ms, Maximum = 0ms, Average = 0ms  

when I try to ping the host, I get this

C:\Users\Jose>ping 192.168.1.199                                                                                                                                                                                                                Pinging 192.168.1.199 with 32 bytes of data:                                                                            
Reply from 192.168.1.119: Destination host unreachable.                                                                 
Reply from 192.168.1.119: Destination host unreachable.                                                                 
Reply from 192.168.1.119: Destination host unreachable.                                                                 
Reply from 192.168.1.119: Destination host unreachable.                                                                                                                                                                                        
Ping statistics for 192.168.1.199:                                                                                          
 Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),     

On a positive note, I am able to ping my router, and I am even able to access the router settings through the browser.

When I use nslookup I get the following

C:\Users\Jose>nslookup                                                                                                  
Default Server:  UnKnown                                                                                                
Address:  192.168.122.1                                                                                                                                                                                                                         >      

This is positive. You should now try to ping internet IPs, like 8.8.8.8.

You can do DNS checks with nslookup. For example

nslookup google.com 

or

nslookup manjaro.org 

Can you configure a DNS in Windows? For DNS use for example 8.8.8.8. If you can ping the router from the VM, you should have internet access.

One more thing to look for is your host firewall settings.

I am able to ping IP 8.8.8.8, but when try DNS checks with nslookup as you mentioned I got the following

C:\Users\Jose>nslookup google.com                                                                                       
Server:  UnKnown                                                                                                        
Address:  192.168.122.1                                                                                                                                                                                                                        
*** UnKnown can't find google.com: Query refused   

@heiko_s as you mentioned I tried configuring the DNS and I used the following settings.

Preferrred DNS server : 8.8.8.8
Alternative DNS server: 8.8.4.4

and that solved my problem, now I am able to access the internet.

@xabbu @heiko_s Thank you for your help and time, helping me troubleshoot this issue.

Great news! Just remember to also turn off memballoon as mentioned in one of my previous posts. For some inexplicable reason virt-manager turns memballoon on by default. It doesn’t work with Windows.

Also note that host-model is not the same as host-passthrough. In many cases host-passthrough is performing better, but there are exceptions.

In addition, there are hypervisor enlightenments (features) that can be turned on. Here is my features section for comparison:

  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state="on"/>
      <vapic state="on"/>
      <spinlocks state="on" retries="8191"/>
      <vpindex state="on"/>
      <runtime state="on"/>
      <synic state="on"/>
      <stimer state="on">
        <direct state="on"/>
      </stimer>
      <reset state="on"/>
      <vendor_id state="on" value="AuthenticAMD"/>
      <frequencies state="on"/>
      <reenlightenment state="on"/>
      <tlbflush state="on"/>
      <ipi state="on"/>
      <evmcs state="off"/>
    </hyperv>
    <kvm>
      <hidden state="on"/>
    </kvm>
    <vmport state="off"/>
    <ioapic driver="kvm"/>
  </features>

In above configuration, you need the section only if you pass through a Nvidia GPU.

Another section that has impact on performance is the timing section (clock):

  <clock offset="localtime">
    <timer name="rtc" tickpolicy="catchup"/>
    <timer name="pit" tickpolicy="delay"/>
    <timer name="hpet" present="no"/>
    <timer name="hypervclock" present="yes"/>
    <timer name="tsc" present="yes" mode="native"/>
  </clock>

Note the last line.

The above examples are only relevant if you want or need to tweak VM performance. If that is not an issue, leave as is and be happy.

I’m glade it is now working for you.

If you still interested in why DNS is not working, do you use systemd-resolved with the stub resolver? Because libvirt starts a dnsmasq process that needs to listen on 192.168.122.1:53, but port 53 might be taken for all addresses by systemd-resolved.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.