Skip Navigation

No internet in virtual machine

I have on the host machine two network interfaces. One is lan and the other is a wlan. For libvirt I have created a nat network which is bound to the wlan. From the guest I can access other machines in the network host wlan is connected to. Also DNS lookup works. The problem is that there's no connection to the internet at all, e.g. pinging something gives "Destination network unreachable". This only happens when both network connection on the host are active. Running qemu/libvirt on OpenSuse Tumbleweed.

The nat network in question:

<network>
  <name>natToWlan</name>
  <uuid>a44c939c-e6bf-44d0-8f86-376056d418a4</uuid>
  <forward dev="wlp19s0f4u1u1" mode="nat">
    <nat>
      <port start="1024" end="65535"/>
    </nat>
    <interface dev="wlp19s0f4u1u1"/>
  </forward>
  <bridge name="virbr1" stp="on" delay="0"/>
  <mac address="52:54:00:1f:64:95"/>
  <ip address="192.168.100.1" netmask="255.255.255.0">
    <dhcp>
      <range start="192.168.100.128" end="192.168.100.254"/>
    </dhcp>
  </ip>
</network>
7

You're viewing a single thread.

7 comments
  • I'm guessing either firewall rules or routing rules are messing up the VM's internet connection. I don't think there's anything wrong with the VM itself.

    If your PC is trying to route every connection to the internet over the ethernet port but your VM is exclusive to the Wi-Fi, this could be a problem. This depends on your host network setup, as Linux is quite capable of having multiple routes to the same origin.

    There's one other theoretical issue I can think of, which is the MTU being too high on the VM side. If the host has an MTU of 1450 and the VM takes an MTU of 1500, packets will be fragmented and many internet services/boxes will not do IP reassembly (as it makes defence against DDoS and other cyber attacks more difficult). In theory MTU path discovery should detect and fix this, but sometimes I find it necessary to manually lower the MTU, especially when things like VPN tunnels are involved.

    • When the host routing table is like this:

      $route
      Kernel IP routing table
      Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
      default         192.168.102.1   0.0.0.0         UG    600    0        0 wlp19s0f4u1u1
      default         RT-AC86U-6D60   0.0.0.0         UG    20100  0        0 enp15s0
      

      the VM has internet connection. If the defaults are the other way around it doesn't.

You've viewed 7 comments.