Find the IP Addresses of KVM Virtual Machines (Command Line)
Gregg
To find details about the virtual network you can use these commands:
root@slacker:~# virsh net-listName State Autostart Persistent--------------------------------------------default active yes yesroot@slacker:~# virsh net-info defaultName: defaultUUID: 14a90f27-9a85-42ca-b434-6ce6c142690cActive: yesPersistent: yesAutostart: yesBridge: virbr0root@slacker:~# virsh net-dhcp-leases defaultExpiry Time MAC address Protocol IP address Hostname Client ID or DUID------------------------------------------------------------------------------------------------------------2023-07-22 16:18:45 52:54:00:dd:7b:62 ipv4 192.168.122.216/24 centos7-bbk -
You will find the IP address and hostname listed in the last command’s output.
Optionally, to find the network interfaces’s addresses for a running domain called centos7-bbk:
root@slacker:~# virsh listId Name State-----------------------------3 centos7-bbk runningroot@slacker:~# virsh domifaddr centos7-bbkName MAC address Protocol Address-------------------------------------------------------------------------------vnet2 52:54:00:dd:7b:62 ipv4 192.168.122.216/24root@slacker:~#