Static DHCP IPs with KVM Virtualization

When building a virtualization lab system, I’ve found that I want static IPs assigned to my guests. You could just assign static IPs in the guest OS, but then you should document what IPs are in use for what hosts. It would be easier to just assign static IP entries in the DHCP server. There doesn’t seem to be a straight-forward way to get this done.

What I’ve found works is to destroy the network, edit it directly, and then restart it.

[root@m77413 libvirt]# virsh -c qemu:///system net-destroy default
Network default destroyed

[root@m77413 libvirt]# virsh -c qemu:///system net-edit default
Network default XML configuration edited.

[root@m77413 libvirt]# virsh -c qemu:///system net-start default
Network default started

The xml file entries should look like:

  <ip address='' netmask=''>
      <range start='' end='' />
      <host mac='52:54:00:10:6e:17' name='cent-install.test' ip='' />
      <host mac='52:54:00:ab:10:2a' name='cent-netserver.test' ip='' />
      <host mac='52:54:00:df:47:95' name='install.test' ip='' />

Leave a Reply

Your email address will not be published.