Provisioning network setup for libvirt

libvirt is a great platform for deploying virtual machine instances. Setting up a provisioning network that assigns IP addresses via DHCP and points to a boot server is quite straightforward.

Create examplenet network definition

[root@coruscant ~]# vim examplenet.xml 
  <forward mode='nat'>
      <port start='1024' end='65535'/>
  <bridge name='virbr3' stp='on' delay='0'/>
  <mac address='36:06:D0:13:85:5D'/>
  <domain name='' localOnly='yes'/>
  <ip address='' netmask=''>
      <range start='' end=''/>
      <bootp file='/pxelinux.0' server=''/>

This XML file specifies a network named examplenet and helps the guest VMs PXE boot from

Define the network

[root@coruscant ~]# virsh net-define examplenet.xml 
Network examplenet defined from examplenet.xml

Start the network

[root@coruscant ~]# virsh net-autostart examplenet
Network examplenet marked as autostarted

[root@coruscant ~]# virsh net-start examplenet
Network examplenet started

Status check

[root@coruscant ~]# virsh net-list
 Name                 State      Autostart     Persistent
 default              active     yes           yes
 examplenet           active     yes           yes
 fdev                 active     yes           yes