How to find ip address of Linux KVM guest virtual machine

www.‮.iruttual‬com
How to find ip address of Linux KVM guest virtual machine

To find the IP address of a Linux KVM guest virtual machine, you can try the following steps:

  1. First, determine the name of the virtual machine. You can use the virsh list --all command to list all the virtual machines on the host system. The output will show the names of the virtual machines and their current state (e.g. running, shut off). For example:
$ virsh list --all
 Id    Name                           State
----------------------------------------------------
 1     centos7                        running
 2     ubuntu1804                     shut off
  1. Once you have the name of the virtual machine, you can use the virsh domifaddr command to show the IP address(es) assigned to it. The --source flag allows you to specify the source of the address (e.g. DHCP, network configuration). For example:
$ virsh domifaddr ubuntu1804
 Name       MAC address          Protocol     Address
-------------------------------------------------------------------------------
 vnet0      52:54:00:9c:b9:f3    ipv4         192.168.122.49/24

Note that this will only work if the virtual machine is running and has network connectivity. If the virtual machine is shut off or disconnected from the network, this command will not be able to retrieve its IP address.

Alternatively, you can also try logging into the virtual machine and using the ifconfig or ip addr command to view the IP address(es) assigned to it. This will work regardless of the state of the virtual machine or its network connectivity.

Created Time:2017-10-28 21:39:03  Author:lautturi