Cockpit: Virtual Machine IP listed as unknown when VM connected via Bridge

Created on 11 Jun 2020  路  8Comments  路  Source: cockpit-project/cockpit

Cockpit version: 220
OS:Fedora 32
Page: Machines

I am creating my virtual machines from Cockpit. There is a bridge connection for my machines to reach host network and VM's connect to network via bridge. When I add the VM to bridge machine connected to external DHCP and take IP address but it still shows as Unknown in Network Interfaces tab. In virt-manager I can see the VM's IP.

Steps to reproduce

  1. Create a bridge network
  2. Create a virtual machine
  3. Add this bridge connection from Network Interface
  4. Run VM and see 谋f it is getting an IP from DHCP
  5. Check network interfaces tab to see IP set to unknown or VM's IP

Most helpful comment

I have the same problem

All 8 comments

I have the same problem

How did you manage to create a bridge in cockpit? (sorry for the OT question, but I just can't figure it out...)

@tophee there鈥檚 add bridge option in network page. I am using fedora 32. Maybe it depends on your distro or package installation.

Thanks @akinomeroglu, good to know. I'm on Debian and there is no such option.

I am doing the same thing, only I created the bridge manually then defined it in virsh so it appears as virbr0-bridge. Created in Fedora 32 before I started using Cockpit. The IP's pull from my primary DHCP on my network.

The only way I have found them so far is based off a script on StackOverflow:
https://stackoverflow.com/questions/14600466/how-to-ping-mac-address-in-linux

!/bin/bash

network=192.168.2.1/24
if [ "$#" -ne 1 ]; then echo Usage example: $0 aa:bb:cc:dd:ee:ff; exit 2; fi;
nmap -sP -T4 $network >& /dev/null
ip=$(arp -n | grep $1 | awk ' { print $1 }')
ping $ip -n -q -c 2 -i 0.2 -w 1 >& /dev/null
if [ $? -eq 0 ]; then
echo Device is online ($ip)
else
echo Device is offline
exit 1
fi;

wrapped in a findmac.sh shell. Called with findmac.sh MAC Address.
Using the Mac Address from the Virtual Machines in the shell script will resolve them if they are running.

Considering that you can pull the IP Address Range i.e. 192.168.2.X/24 from the Networking Section for the bridge name, use that in the network variable above and it still works, if I knew Cockpit design better, this could be pulled dynamically for all the MAC Addresses listed in the Virtual Machines or at least put in a different page pulling the MAC addresses.

There are multiple ways to get IP address of a virtual machine. In libvirt these three are implemented:

  1. ARP table parsing - this is basically what the script in the above comment does
  2. Leases file parsing - when the virtual machine has an interface attached to a libvirt NATed network, dnsmasq is spawned (by libvirt) and the dnsmasq is instructed to update a JSON file on every DHCP traffic which is then parsed by libvirt
  3. Agent - libvirt communicates with the qemu guest agent running inside the VM to get the IP addresses.

Since this bug is not about libvirt NATed network, only ARP and Agent can be used. I don't know what cockpit uses.

Actually, leases would work for any network where libvirt spawns dnsmasq, but this is not the case.

BTW: Libvirt has this NSS plugin which allows you to translate VM names into IP addresses. It works only for networks where dnsmasq is spawned (= it uses leases file parsing as described above). Maybe it's interesting to cockpit users? You could just ssh guest instead of having to find out guest's IP address first.

I will comment on my issue here is for #2 that involves getting the IP from libvirt and not an external DHCP. Where the OP and Myself are using an external DHCP, in my case my routers, to assign IP addresses through the interface bridge. As for #3. I have the Agent installed on the VMs and can see it, but libvirt itself doesn't see the IP address. I figure it is due to the external DHCP assignment. Which leaves option #1. Now figuring out how to code this into a module is the part I need to figure out.

Was this page helpful?
0 / 5 - 0 ratings