简体   繁体   中英

virsh domifaddr <domain-name> does not show KVM IPs

I created a virtual machine on my centos server machine by using the virt-manager.
While the installation, I have set a static IP address on the KVM.
When I tried to get the IP address of KVM from my centos server terminal by using virsh domifaddr <domain-name> , it shows nothing.

I suspected that this might happen because I set the static IP address on the KVM.
This is a part of my virsh dumpxml <domain-name> output.

<interface type='direct'>
  <mac address='52:54:00:cf:67:0f'/>
  <source dev='eth0' mode='bridge'/>
  <target dev='macvtap4'/>
  <model type='virtio'/>
  <alias name='net0'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
  <source path='/dev/pts/8'/>
  <target type='isa-serial' port='0'>
    <model name='isa-serial'/>
  </target>
  <alias name='serial0'/>
</serial>
<console type='pty' tty='/dev/pts/8'>
  <source path='/dev/pts/8'/>
  <target type='serial' port='0'/>
  <alias name='serial0'/>
</console>

As shown above it says 'direct' as the type of the interface. Would it be the problem? and how can I fix the problem?

The domifaddr command has two sources of information it can use. When using <inteface type='network'/> it consults the DHCP lease database maintained by the dnsmasq instance libvirt spawns for the virtual network. If the QEMU guest agent is installed and running, it can also query the agent for the info from the guest OS POV. The --source arg can control which data source is used.

With your use of <interface type='direct'/> there will be no DHCP lease database available, so guest agent will be the only remaining option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM