virsh domifaddr domain does not show static IP

Hi, I have assigned static IP for all the below KVM Guest VM's. Is there a way to find out the IP of the below VM's from virsh utility or any other utility? virsh domifaddr testdobssbahrainms does not show the static IP. # virsh list --all Id Name State ----------------------------------------- 1 testdobssbahrainms running 2 testdosstomcatpibms running 3 testdobsstomcatkineticms running 4 testdobsstomcatmsbms running 5 testdobsstomcatfdms running 6 testdobsstomcathsbcnetms running 7 testdobsstomcatdbbms running 8 testdobssapigeedev running # # virt-install --version 2.2.1 # cat /etc/redhat-release CentOS Stream release 8 #virsh domifaddr testdobssbahrainms #Name MAC address Protocol Address ------------------------------------------------------------------------------- Please guide. Thanks in advance. Best Regards, Kaushal

On 9/9/21 2:11 PM, Kaushal Shriyan wrote:
Hi,
I have assigned static IP for all the below KVM Guest VM's. Is there a way to find out the IP of the below VM's from virsh utility or any other utility? virsh domifaddr testdobssbahrainms does not show the static IP.
By default, "virsh domifaddr" will attempt to lookup the MAC address of the guest interface in the table of IP addresses leased from the libvirt-managed dhcp server for the network the interface is connected to. If the interface has a statically configured IP, or if it isn't connected to a libvirt-managed virtual network, then no IP addresses will be found. You can change this behavior with the "--source" option: '--source arp' - looks for the MAC address in the host's ARP table '--source agent' - queries the guest agent (which must have been installed) Each of these has varying levels of reliability and success, depending on your specific setup. e.g., if the guests don't have the guest agent installed, that method will fail, and if the guest can't be trusted, then any information it sends also can't be trusted. Alternately, it is possible for an external device on the network to poison the ARP table with bad information, and it's also possible that the guest simply has no entry in the ARP table (if the host has never attempted to communicate with it, or if it's connected via a host interface/bridge that itself has no IP address.) Hmm, and I guess --source arp also wouldn't work for guests connected via macvtap (<interface type='direct'>) since guest<->host communication isn't supported in that case (and so the guest could never show up in the host's ARP table). Anyway if your guests are connected to a libvirt virtual network or to a Linux host bridge that has an IP address on the host, then "--source arp" should work for you.
# virsh list --all Id Name State ----------------------------------------- 1 testdobssbahrainms running 2 testdosstomcatpibms running 3 testdobsstomcatkineticms running 4 testdobsstomcatmsbms running 5 testdobsstomcatfdms running 6 testdobsstomcathsbcnetms running 7 testdobsstomcatdbbms running 8 testdobssapigeedev running
# # virt-install --version 2.2.1 # cat /etc/redhat-release CentOS Stream release 8
#virsh domifaddr testdobssbahrainms #Name MAC address Protocol Address -------------------------------------------------------------------------------
Please guide. Thanks in advance.
Best Regards,
Kaushal

On Fri, Sep 10, 2021 at 12:08 AM Laine Stump <laine@redhat.com> wrote:
On 9/9/21 2:11 PM, Kaushal Shriyan wrote:
Hi,
I have assigned static IP for all the below KVM Guest VM's. Is there a way to find out the IP of the below VM's from virsh utility or any other utility? virsh domifaddr testdobssbahrainms does not show the static IP.
By default, "virsh domifaddr" will attempt to lookup the MAC address of the guest interface in the table of IP addresses leased from the libvirt-managed dhcp server for the network the interface is connected to. If the interface has a statically configured IP, or if it isn't connected to a libvirt-managed virtual network, then no IP addresses will be found. You can change this behavior with the "--source" option:
'--source arp' - looks for the MAC address in the host's ARP table '--source agent' - queries the guest agent (which must have been installed)
Each of these has varying levels of reliability and success, depending on your specific setup. e.g., if the guests don't have the guest agent installed, that method will fail, and if the guest can't be trusted, then any information it sends also can't be trusted. Alternately, it is possible for an external device on the network to poison the ARP table with bad information, and it's also possible that the guest simply has no entry in the ARP table (if the host has never attempted to communicate with it, or if it's connected via a host interface/bridge that itself has no IP address.)
Hmm, and I guess --source arp also wouldn't work for guests connected via macvtap (<interface type='direct'>) since guest<->host communication isn't supported in that case (and so the guest could never show up in the host's ARP table).
Anyway if your guests are connected to a libvirt virtual network or to a Linux host bridge that has an IP address on the host, then "--source arp" should work for you.
# virsh list --all Id Name State ----------------------------------------- 1 testdobssbahrainms running 2 testdosstomcatpibms running 3 testdobsstomcatkineticms running 4 testdobsstomcatmsbms running 5 testdobsstomcatfdms running 6 testdobsstomcathsbcnetms running 7 testdobsstomcatdbbms running 8 testdobssapigeedev running
# # virt-install --version 2.2.1 # cat /etc/redhat-release CentOS Stream release 8
#virsh domifaddr testdobssbahrainms #Name MAC address Protocol Address
-------------------------------------------------------------------------------
Please guide. Thanks in advance.
Best Regards,
Kaushal
Thanks Laine for the detailed explanation. The below command worked. Thanks a lot and appreciate it. virsh domifaddr testdobssbahrainms --source agent Name MAC address Protocol Address ------------------------------------------------------------------------------- lo 00:00:00:00:00:00 ipv4 127.0.0.1/8 eth0 52:14:00:74:11:14 ipv4 192.168.0.113/24 Is there a way to find out the Static IP address if the KVM Guest VM instance is shut off? Thanks in advance. Best Regards, Kaushal

On 9/9/21 10:07 PM, Kaushal Shriyan wrote:
Thanks Laine for the detailed explanation. The below command worked. Thanks a lot and appreciate it.
virsh domifaddr testdobssbahrainms --source agent
Name MAC address Protocol Address ------------------------------------------------------------------------------- lo 00:00:00:00:00:00 ipv4 127.0.0.1/8 <http://127.0.0.1/8> eth0 52:14:00:74:11:14 ipv4 192.168.0.113/24 <http://192.168.0.113/24>
Is there a way to find out the Static IP address if the KVM Guest VM instance is shut off? Thanks in advance.
Maybe? In the case of --source agent, the guest must be queried, and the guest is no longer running so it can't answer. In the other cases, libvirt is looking for the name of the tap device used by the guest interface, but the tap device no longer exists. So libvirt doesn't provide any method. However, if the guest was recently running, there may still be an entry left in the arp cache, and you would be able to see it by grepping (on the host, of course) for the guest's MAC address, like this: arp -an | grep 52:14:00:74:11:14 That's not going to work if the guest has been down for longer than the timeout of the arp cache though (or if the guest hasn't communicated with the host in any manner for that amount of time).

On 9/10/21 4:07 AM, Kaushal Shriyan wrote:
Is there a way to find out the Static IP address if the KVM Guest VM instance is shut off? Thanks in advance.
This strongly depends on where you configure the static IP. If it's a libvirt managed network then you can just dump the network XML and run fairly trivial XPATH to learn the IP address. But if you use something else to assign IP addresses, something that's outside of libvirt's scope then I guess what Laine wrote in the other reply is your only hope. Michal
participants (3)
-
Kaushal Shriyan
-
Laine Stump
-
Michal Prívozník