<p>If you don’t want to do any configuration inside the guest, then the only option is a DHCP server that hands out static IP addresses. If you use <code>bridge</code> mode, that will probably be some external DHCP server. Consult its manual to find out how to serve static leases.</p>
<p>But at least in forward modes <code>nat</code> or <code>route</code>, you could use libvirt’s built-in <code>dnsmasqd</code> (More recent versions of libvirtd support the dnsmasq’s “dhcp-hostsfile” option). Here is how:</p>
<p>First, find out the MAC addresses of the VMs you want to assign static IP addresses:</p>
<pre><code class="lang-auto">virsh dumpxml $VM_NAME | grep 'mac address'
</code></pre>
<p>Then edit the network</p>
<pre><code class="lang-auto">virsh net-list
virsh net-edit $NETWORK_NAME # Probably "default"
</code></pre>
<p>Find the <code><dhcp></code> section, restrict the dynamic range and add host entries for your VMs</p>
<pre><code class="lang-auto"><dhcp>
<range start="192.168.122.100" end="192.168.122.254"/>
<host mac="52:54:00:6c:3c:01" name="vm1" ip="192.168.122.11"/>
<host mac="52:54:00:6c:3c:02" name="vm2" ip="192.168.122.12"/>
<host mac="52:54:00:6c:3c:03" name="vm3" ip="192.168.122.13"/>
</dhcp>
</code></pre>
<p>Then, reboot your VM (or restart its DHCP client, e.g. <code>ifdown eth0; ifup eth0</code>)</p>
<p>Update: I see there are reports that the change might not get into effect after “virsh net-edit”. In that case, try this after the edit:</p>
<pre><code class="lang-auto">virsh net-destroy $NETWORK_NAME
virsh net-start $NETWORK_NAME
</code></pre>
<p>… and restart the VM’s DHCP client.</p>
<p>If that still doesn’t work, you might have to</p>
<ul>
<li>
<p>stop the libvirtd service</p>
</li>
<li>
<p>kill any dnsmasq processes that are still alive</p>
</li>
<li>
<p>start the libvirtd service</p>
</li>
</ul>
<p>Note: There is no way the KVM host could force a VM with unknown OS and unknown config to use a certain network configuration. But if know know that the VM uses a certain network config protocol - say DHCP - you can can use that. This is what this post assumes.</p>
<p><em>Some</em> OS (e.g. some Linux distros) also allow to pass network config options into the guest e.g. via the kernel command line. But that is very specific to the OS, and i see no advantage over the DHCP method.</p>