This post will describe how to modify dhcp configuration for a kvm guest.

the first step is to list the current virtual network :

# virsh net-list
Name                 State      Autostart     Persistent
--------------------------------------------------
default              active     yes           yes
isolated             active     yes           yes

I want to modify the default network. So i edit it with virsh net-edit default :

The original configuration file for my nat network is :

<network>
  <name>default</name>
  <uuid>f4f6e3c0-2319-4aef-b030-8eb4007c391d</uuid>
  <forward mode='nat'/>
  <bridge name='virbr0' stp='on' delay='0' />
  <mac address='52:54:00:15:40:34'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254' />
    </dhcp>
  </ip>
</network>

I want to assign a ip address to my guest vm devel2, so i add a host line in the xml file :

<network>
  <name>default</name>
  <uuid>f4f6e3c0-2319-4aef-b030-8eb4007c391d</uuid>
  <forward mode='nat'/>
  <bridge name='virbr0' stp='on' delay='0' />
  <mac address='52:54:00:15:40:34'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.100' end='192.168.122.254' />
      <host mac='52:54:00:7a:41:34' name='devel2' ip='192.168.122.10' />
    </dhcp>
  </ip>
</network>

To enable the new configuration, i need to run the following commands :

# virsh net-destroy default
Network default destroyed
# virsh net-start default
Network default started