3

I've configured a host-only (aka private) network for a group of VMs on a CentOS 7 host. I've created static leases in the DHCP section for the virtual network.

The IP address is getting set correctly, but the hostname is ignored. Instead, it's falling back to the transient hostname. Here's the output of hostnamectl:

Static hostname: n/a
Transient hostname: vmname
  Icon name: computer-vm
    Chassis: vm
 Machine ID: 7944dc3acb404c81b272fb8ac4b047fd
    Boot ID: ac7efda81d644700a9a51a9cff9c12cb
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
     Kernel: Linux 3.10.0-327.13.1.el7.x86_64
Architecture: x86-64

This is my network configuration:

<network>
    <name>virtnet1</name>
    <bridge name="virbr1" />
    <ip address="10.2.2.101" netmask="255.255.255.0">
        <dhcp>
            <range start='10.2.2.30' end='10.2.2.99'/>
            <host mac='52:54:00:a3:5d:44' name='myhost' ip='10.2.2.9'/>
        </dhcp>
    </ip>
</network>
orodbhen
  • 161
  • 8

1 Answers1

2

You need to set DHCP Options List for the host.

Like this for standard DHCP:

host **foobar** {
hardware ethernet c0:18:85:e3:13:31;
fixed-address 10.1.1.129;
option domain-name "**example.org**";
option host-name "foobar";
ddns-hostname "**foobar.mydomain.com**";
}

EDIT

Like this for libvirt: Please note you must have the patch for libvirt as this Bug 824573 has been active for some time. The patch information can be found here.

<network>
    <name>virtnet1</name>
    <bridge name="virbr1" />
    <ip address="10.2.2.101" netmask="255.255.255.0">
        <dhcp>
            <range start='10.2.2.30' end='10.2.2.99'/>
            <host mac='52:54:00:a3:5d:44' name='myhost' ip='10.2.2.9'/>
            <option number="12" value="foobar" /> 
            <option number="15" value="mydomain.com" />
            <option number="42" value="NTP Servers" />
            <option number="56" value="DHCP Message" />
        </dhcp>
    </ip>
</network>
pool pro
  • 170
  • 4
  • Correct me if I'm wrong, but that's for configuring a stand alone DHCP service, not libvirt's built in service. – orodbhen May 23 '16 at 09:16
  • The bug you linked to talks about adding extended options to the libvirtd DHCP configuration. I only need IP and hostname, based on the MAC. The libvirt networking documentation implies that this is supported by default. – orodbhen May 24 '16 at 15:12