[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: virsh domifaddr domain does not show static IP





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

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]