0

I have an XML template for the image I am loading on KVM using ansible. For now, the image loads without IP. I would like to know if there is a way to add static IP on the XML template so that my VM loads with static IP on eth0 interface.

I tried the below in XML but it shows ERR "libvirtError: unsupported configuration: Invalid attempt to set network interface guest-side IP route and/or address info, not supported by QEMU"

<interface type='bridge'>
      <source bridge='veth0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
      <ip address='172.x.x.x' netmask='255.255.254.0' gateway='172.x.x.1' dns-nameserver='x.x.x.x'>
      </ip>
    </interface>

Please suggest a way, Thanks

ranji
  • 21
  • 6
  • It is up to guest OS to set guest IP, often that is done with DHCP, in bridged mode that DHCP would be your main DHCP, you could controll it based on MAC. – NiKiZe Sep 04 '21 at 13:32
  • Hi, Thanks ! DHCP works. But in my case, I have deployed 50 VMs and each VM has multiple interfaces. So I am looking at if there is a way around to do this static IP setting using virsh command or using the template to reduce the work. – ranji Sep 04 '21 at 13:42
  • Not sure if I can explain it clearer, There is no way in virsh to configure "static ip" in guest. The closest is to have DHCP in guest, and then virsh/qemu can give out the configured IP to the guest by DHCP - however, since you are using bridged network virsh/qemu is no longer in control of the interface, and you need to configure this on your networks DHCP server - you can use the guests MAC address to do so. – NiKiZe Sep 04 '21 at 14:11

0 Answers0