[libvirt-users] Automatically assign static ipv4 via dhcp to new VMs

Tim tim at online-mail.biz
Fri Oct 4 16:09:53 UTC 2013


Hi guys,

I'm running a KVM/libvirt host in a datacenter and got a fancy IPv4
subnet from my provider. I'm able to assign IPs from that subnet via
dhcp to my VMs:

host01 ~ # virsh net-dumpxml internet
<network connections='3'>
  <name>internet</name>
  <uuid>37b888cc-510f-46f1-9246-346da96222ed</uuid>
  <forward dev='enp5s0f0' mode='route'>
    <interface dev='enp5s0f0'/>
  </forward>
  <bridge name='virbr1' stp='on' delay='0'/>
  <mac address='52:54:00:13:39:d5'/>
  <ip address='XX.YY.253.2' netmask='255.255.255.224'>
    <dhcp>
      <range start='XX.YY.253.4' end='XX.YY.253.30'/>
      <bootp file='pxelinux.0' server='XX.YY.99.100'/>
    </dhcp>
  </ip>
</network>



What I would like to do:

1) Right know it seems like dnsmasq assigns ip-addresses randomly to
VMs, is there any way to assign them in ascending order?

2) IPs are not statically assigned. Is it possible to add something like
this automatically at the first VM-start to the xml definition?:
<host mac='AA:BB:CC:DD:EE:FF' ip='192.168.122.2' name='foobar'/>




More information about the libvirt-users mailing list