Sample Header Ad - 728x90

Specify unique DHCP hostnames for multiple network interfaces

2 votes
2 answers
2515 views
I am running Ubuntu Server 20.04 in a VM under ESXi on my home server. I would like the VM to have two unique IP addresses, with the goal of being able to run two separate instances of PiHole in docker containers. I have configured two network adapters on the VM, and then configured /etc/netplan/00-installer-config.yaml as:
network:
  ethernets:
    ens160:
      dhcp4: true
    ens192:
      dhcp4: true
  version: 2
After running netplan apply, I have two interfaces, each with their own IP via DHCP.
# ifconfig
ens160: flags=4163  mtu 1500
        inet 10.0.0.212  netmask 255.255.255.0  broadcast 10.0.0.255
...
ens192: flags=4163  mtu 1500
        inet 10.0.0.213  netmask 255.255.255.0  broadcast 10.0.0.255
...
I have then edited /etc/dhcp/dhclient.conf by commenting out the default 'send host-name' option and replacing it with two interface-specific options:
#send host-name = gethostname();
interface "ens160" {
    send host-name = "something-else-1";
}

interface "ens192" {
    send host-name = "something-else-2";
}
It's this step that does not seem to work. The DHCP server (Unifi) still reports the hostname as 'experimental'. In fact, I tried just changing the existing gethostname() line to just have some other hostname, and even that does not seem to work. I tried changing /etc/hostname to use something different, and that did work. So it seems like the options in /etc/dhcp/dhclient.conf are just being ignored for some reason. Can anyone tell me what I'm doing wrong? Thanks!
Asked by antsyawn (121 rep)
Jun 27, 2020, 02:53 AM
Last activity: Jun 9, 2025, 07:03 PM