Ubuntu – Configure multiple interfaces with different hostnames using DHCP and DNS

dhcpdnsfreebsdnetworkingUbuntu

I have a machine running Ubuntu 12.04 Server with two interfaces connected (eth0, eth1) to the network. Our network is set up so that a FreeBSD based DHCP server hands out leases and registers the client supplied host names with a DNS server on the same network.

The two interfaces need to have different host names to register both on DNS. In /etc/network/interfaces I have added the hostname for eth1:

# The primary network interface (hostname: host0)
auto eth0
iface eth0 inet dhcp

# Secondary interface 
auto eth1
iface eth1 inet dhcp
  hostname host1

The dhcp client config looks something like this:

    option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

    send host-name "<hostname>";
    request subnet-mask, broadcast-address, time-offset, routers,
            domain-name, domain-name-servers, domain-search, host-name,
            netbios-name-servers, netbios-scope, interface-mtu,
            rfc3442-classless-static-routes, ntp-servers,
            dhcp6.domain-search, dhcp6.fqdn,
            dhcp6.name-servers, dhcp6.sntp-servers;

The leases obtained look like this:


# /var/run/resolvconf/interface/eth0.dhclient
lease {
  interface "eth0";
  fixed-address 192.168.28.249;
  option subnet-mask 255.255.255.0;
  option routers 192.168.28.30;
  option dhcp-lease-time 129600;
  option dhcp-message-type 5;
  option domain-name-servers 192.168.28.1,192.168.24.58;
  option dhcp-server-identifier 192.168.28.1;
  option ntp-servers 192.168.28.1,192.168.58.43,192.168.24.58;
  option broadcast-address 192.168.28.255;
  option domain-name "some.org";
  renew 4 2014/02/20 01:00:39;
  rebind 4 2014/02/20 15:31:19;
  expire 4 2014/02/20 20:01:19;
}

# /var/run/resolvconf/interface/eth1.dhclient
lease {
  interface "eth1";
  fixed-address 192.168.19.69;
  option subnet-mask 255.255.255.0;
  option routers 192.168.19.30;
  option dhcp-lease-time 129600;
  option dhcp-message-type 5;
  option domain-name-servers 192.168.28.1,192.168.24.58;
  option dhcp-server-identifier 192.168.28.1;
  option ntp-servers 192.168.28.1,192.168.58.43,192.168.24.58;
  option broadcast-address 192.168.19.255;
  option domain-name "some.org";
  renew 3 2014/02/19 21:56:46;
  rebind 4 2014/02/20 15:30:42;
  expire 4 2014/02/20 20:00:42;
}

I do not have control over the FreeBSD DHCP server, but have been told the leases were recorded as:


#####################
lease 192.168.28.249 {
starts 5 2014/02/14 03:24:14;
ends 6 2014/02/15 15:24:14;
cltt 5 2014/02/14 03:24:14;
binding state active;
next binding state free;
hardware ethernet 00:01:02:03:04:12;
set ddns-rev-name = "249.28.168.192.in-addr.arpa.";
set ddns-fwd-name = "host0.dhcp.some.org";
client-hostname "host0";
on expiry or release {
switch (ns-update (delete (1, 12, ddns-rev-name, null))) {
case 0:
unset ddns-rev-name ;
break;
}
switch (ns-update (delete (1, 1, ddns-fwd-name, leased-address))) {
case 0:
unset ddns-fwd-name ;
break;
}
on expiry or release;
}
}
lease 192.168.19.69 {
starts 4 2014/02/13 14:40:47;
ends 6 2014/02/15 02:40:47;
cltt 4 2014/02/13 14:40:47;
binding state active;
next binding state free;
hardware ethernet 00:01:02:03:04:14;
client-hostname "host0";
}

#####################

In both leases on the server side the client-hostname has the value "host0". Note that the leases were handed out on two different subnets: 192.168.28.0 and 192.168.19.0.

Is my /etc/network/interfaces configuration all that is needed for sending the secondary interface's hostname to the DHCP server? If so, what else should I check on the client side to debug?

(IP addresses and MAC addresses were modified to hide real values)

Best Answer

I'm not 100% sure if what you want is possible purely by setting options in /etc/network/interfaces.

In theory, it's possible by editing /etc/dhcp/dhclient.conf. Try adding a stanza like:

interface "eth0" {
    send host-name "host0";
}

interface "eth1" {
    send host-name "host1";
}

Make sure any other host-name options in that file are commented out and remove the hostname you specified in /etc/network/interfaces.

Related Question