Benutzer-Werkzeuge

Webseiten-Werkzeuge


projects:staticip

Dies ist eine alte Version des Dokuments!


statische IP-Adressen per dhcp im Virt-Manager

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 bridge mode, that will probably be some external DHCP server. Consult its manual to find out how to serve static leases.

But at least in forward modes nat or route, you could use libvirt's built-in 'dnsmasq' (More recent versions of libvirtd support the dnsmasq's „dhcp-hostsfile“ option). Here is how:

First, find out the MAC addresses of the VMs you want to assign static IP addresses:

virsh  dumpxml  $VM_NAME | grep 'mac address'

Then edit the network

virsh  net-list
virsh  net-edit  $NETWORK_NAME    # Probably "default"

Find the <dhcp> section, restrict the dynamic range and add host entries for your VMs

<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.12'/>
</dhcp>

Then, stop and start the network and reboot your VM (or restart its DHCP client, e.g. ipdown eth0; ifup eth0)

projects/staticip.1541783387.txt.gz · Zuletzt geändert: 2018-11-09 17:09 von andreas