I'm running mostly Ubuntu VMs in an vSphere cluster where a VLAN is managed by a Windows DHCP and DNS. From the Ubuntu VMs I can update the DNS records in the Windows DNS to point the dynamic IP to its hostname (set in /etc/hostname
) with dhcp-identifier: mac
addition in /etc/netplan/00-installer-config.yaml
:
cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens160:
dhcp4: true
dhcp-identifier: mac
version: 2
After these modification a call to dhclient -r
also updates the DNS record to point to the newly dhcp-assigned IP address.
But now I want to achieve the same DNS update functionality in a CentOS 7 VM. First I setted /etc/hostname
to myhost.example.tld
and rebooted the machine. After that I tried to change serveral variables in /etc/sysconfig/network-scripts/ifcfg-ens192
:
- Setting
MACADDR
to eitherpreserve
orpermanent
- Setting
DHCP_HOSTNAME
tomyhost
but notDHCP_FQDN
- Setting
DHCP_FQDN
tomyhost.example.tld
but notDHCP_HOSTNAME
Every change to ifcfg-ens192 were followed by the invocation of dhclient -r ens192; dhclient ens192
and a reboot.
I just found the solution. One needs to create
/etc/dhcp/dhclient.conf
and addsend fqdn.fqdn = gethostname();
to it. After that, adhclient -r; dhclient
sends the hostname in the DHCP* message.