Debbuging network while using virtual environments | how to

Since longer i have network troubles while using virt-manager.

When i start my computer i can open the virt-manager and startup a virtual image.
If i do stop/start the with the network-manager-applet from the host i do have problems to connect when i start a new virtual image.

I can’t ping a host in internet. It says cant resolve host name.
Pinging to the internet address also not works.

lspci -nn |egrep -i 'ethernet|wifi'

00:19.0 Ethernet controller [0200]: Intel Corporation 82579LM Gigabit Network Connection (Lewisville) [8086:1502] (rev 04)
04:00.0 Network controller [0280]: Realtek Semiconductor Co., Ltd. RTL8188CE 802.11b/g/n WiFi Adapter [10ec:8176] (rev 01)
06:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 03)

Network:
  Device-1: Intel 82579LM Gigabit Network driver: e1000e v: kernel port: 4080
    bus-ID: 00:19.0
  Device-2: Realtek RTL8188CE 802.11b/g/n WiFi Adapter vendor: AzureWave
    driver: rtl8192ce v: kernel port: 3000 bus-ID: 04:00.0
  Device-3: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    driver: r8169 v: kernel port: 2000 bus-ID: 06:00.0

Thanks for some helpful thoughts to find the culprit of the network issues.

Proposals to debug (It is a Wiki, level 3 can edit it):

nmcli d

DEVICE   TYPE      STATE                   CONNECTION 
enp0s25  ethernet  connected               Lan01      
virbr0   bridge    connected (externally)  virbr0

sudo sed $'s/\^\[/\E/g' /var/log/boot.log |grep -i network

[  OK  ] Stopped target Network.
         Starting Import network configuration from initramfs...
[  OK  ] Finished Import network configuration from initramfs.
         Starting Network Name Resolution...
[  OK  ] Started Network Name Resolution.
[  OK  ] Reached target Host and Network Name Lookups.
[  OK  ] Reached target Preparation for Network.
         Starting Network Manager...
[  OK  ] Started Network Manager.
[  OK  ] Reached target Network.
         Starting Network Manager Wait Online...
         Starting Network Manager Script Dispatcher Service...
[  OK  ] Started Network Manager Script Dispatcher Service.
[  OK  ] Finished Network Manager Wait Online.
[  OK  ] Reached target Network is Online.

sudo sed $'s/\^\[/\E/g' /var/log/boot.log |grep -i libvirt

[  OK  ] Listening on Libvirt local socket.
[  OK  ] Listening on Libvirt admin socket.
[  OK  ] Listening on Libvirt local read-only socket.
[  OK  ] Listening on Libvirt interface local socket.
[  OK  ] Listening on Libvirt nodedev local socket.
[  OK  ] Listening on Libvirt nwfilter local socket.
[  OK  ] Listening on Libvirt storage local socket.

p.s.
the above commands are made on the host after starting it.

I found a hint …

nmcli d

DEVICE   TYPE      STATE        CONNECTION 
enp0s25  ethernet  connected    Lan01      
virbr0   bridge    unmanaged    --         
lo       loopback  unmanaged    --

After enabling networking with the Network-Manager-Applet
the virbr0 keeps unmanaged.

nmcli d connect virbr0

Error: Failed to add/activate new connection: mismatching interface name 

I probably can’t reactivate it with nmcli because i managed it with libvirt-manager?
I might have to create and start with nmcli ?
Then when i switch off network to reconnect automatically ?
Is this possible ?

The real question here is how you configured the guest for network, and what you are using for managing the guest. It looks like you are using libvirt and possibly virt-manager because of the tags, but you did not state it

I am using qemu & virt-manager to manage my VMs. When I set one up I select bridged mode for the network and connect them to virbr0 on the host. Managing it this way I have never had an issue with connecting between the guest & host (both ways) nor have I ever had an issue where the guest was unable to connect to the internet.

When I first tried setting up a VM I used the default network config (NAT) and had issues. After I switched to using the bridged mode I have had no issues.

On the host I show the first when 2 VMs are active and the second when both are powered off.

$ nmcli d
DEVICE          TYPE      STATE                   CONNECTION 
wlp4s0          wifi      connected               MeierMedia 
virbr0          bridge    connected (externally)  virbr0     
vnet0           tun       connected (externally)  vnet0      
vnet1           tun       connected (externally)  vnet1      
p2p-dev-wlp4s0  wifi-p2p  disconnected            --         
enp6s0          ethernet  unavailable             --         
lo              loopback  unmanaged               --         


$ nmcli d
DEVICE          TYPE      STATE                   CONNECTION 
wlp4s0          wifi      connected               MeierMedia 
virbr0          bridge    connected (externally)  virbr0     
p2p-dev-wlp4s0  wifi-p2p  disconnected            --         
enp6s0          ethernet  unavailable             --         
lo              loopback  unmanaged               --         

By having the IP for each of the guests in /etc/hosts (on both guests and on the host) I am also able to directly ssh between any of the 3 machines using the host names.

2 Likes

That is what I did so far default with NAT. I do have problems this way.
I followed your explanation and I was able to get a connection to the internet with a guest In bridged mode. I even could ping the host what i never could because of NAT. Unfortunately next day while booting i not was able to connect the same way.

Anyway thanks a lot for your explanations. Before libvirt I used Virtualbox and I could always connect bridged mode.

I will try again on the weekend when things are more calm. I will give feedback.

P.s.
the libvirt quick dock has been actualized. There is also a bridged connection. I will check this out too.
https://docs.fedoraproject.org/en-US/quick-docs/getting-started-with-virtualization/

OK, I had some time on the weekend to fiddle around again. Details of the connection type below.
Bridged

# QEMU/KVM - Connection Details

<network connections="1">
  <name>mynet</name>
  <uuid>2c1aecfa-5c72-4de4-8d38-be17cbe9a380</uuid>
  <forward mode="open"/>
  <bridge name="virbr0" stp="on" delay="0"/>
  <mac address="52:54:00:e9:c3:c6"/>
  <domain name="example.com"/>
  <ip address="10.0.1.1" netmask="255.255.255.0">
    <dhcp>
      <range start="10.0.1.128" end="10.0.1.254"/>
    </dhcp>
  </ip>
</network>

# Guest network interface

<interface type="network">
  <mac address="52:54:00:12:cc:8c"/>
  <source network="mynet" portid="65ff68d4-137f-43a1-a617-0f3ff4247d67" bridge="virbr0"/>
  <target dev="vnet0"/>
  <model type="e1000e"/>
  <alias name="net0"/>
  <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
</interface>

With fixed IP i generally got connection, but this way i not have access to the internet.

So, how do i debug that ?

@computersavvy, are you using DHCP for your client in the VM?