Stop sending FQDN by default.

Instead, if sending the hostname in DHCPv4, send a FQDN in DHCPv6.

This allows for a cleaner configuration file and fixes some DDNS problems
with upstream servers.
This commit is contained in:
Roy Marples 2013-07-22 19:05:54 +00:00
parent 0a4869d4b8
commit 2326c6baed
3 changed files with 39 additions and 33 deletions

31
dhcp.c
View File

@ -986,25 +986,10 @@ make_message(struct dhcp_message **message,
}
}
/* Regardless of RFC2132, we should always send a hostname
* upto the first dot (the short hostname) as otherwise
* confuses some DHCP servers when updating DNS.
* The FQDN option should be used if a FQDN is required. */
if (ifo->hostname[0] == '\0')
hostname = get_hostname();
else
hostname = ifo->hostname;
if (ifo->options & DHCPCD_HOSTNAME && hostname) {
*p++ = DHO_HOSTNAME;
hp = strchr(hostname, '.');
if (hp)
len = hp - hostname;
else
len = strlen(hostname);
*p++ = len;
memcpy(p, hostname, len);
p += len;
}
if (ifo->fqdn != FQDN_DISABLE) {
/* IETF DHC-FQDN option (81), RFC4702 */
*p++ = DHO_FQDN;
@ -1031,6 +1016,22 @@ make_message(struct dhcp_message **message,
*lp += ul;
p += ul;
}
} else if (ifo->options & DHCPCD_HOSTNAME && hostname) {
*p++ = DHO_HOSTNAME;
/*
* Regardless of RFC2132, we should always send a
* hostname upto the first dot (the short hostname) as
* a FQDN confuses some DHCP servers when updating DNS.
* The FQDN option should be used if a FQDN is wanted.
*/
hp = strchr(hostname, '.');
if (hp)
len = hp - hostname;
else
len = strlen(hostname);
*p++ = len;
memcpy(p, hostname, len);
p += len;
}
/* vendor is already encoded correctly, so just add it */

31
dhcp6.c
View File

@ -380,6 +380,7 @@ dhcp6_makemessage(struct interface *ifp)
uint32_t u32;
const struct ipv6_addr *ap;
const char *hostname = NULL; /* assignment just to appease GCC*/
int fqdn;
state = D6_STATE(ifp);
if (state->send) {
@ -387,8 +388,22 @@ dhcp6_makemessage(struct interface *ifp)
state->send = NULL;
}
/* Work out option size first */
ifo = ifp->options;
fqdn = ifo->fqdn;
if (fqdn == FQDN_DISABLE || ifo->options & DHCPCD_HOSTNAME) {
/* We're sending the DHCPv4 hostname option, so send FQDN as
* DHCPv6 has no FQDN option and DHCPv4 must not send
* hostname and FQDN according to RFC4702 */
if (fqdn == FQDN_DISABLE)
fqdn = FQDN_BOTH;
if (ifo->hostname[0] == '\0')
hostname = get_hostname();
else
hostname = ifo->hostname;
}
/* Work out option size first */
n_options = 0;
len = 0;
si = NULL;
@ -405,13 +420,8 @@ dhcp6_makemessage(struct interface *ifp)
if (len)
len += sizeof(*o);
if (ifo->fqdn != FQDN_DISABLE) {
if (ifo->hostname[0] == '\0')
hostname = get_hostname();
else
hostname = ifo->hostname;
if (fqdn != FQDN_DISABLE)
len += sizeof(*o) + 1 + encode_rfc1035(hostname, NULL);
}
}
len += sizeof(*state->send);
@ -617,11 +627,11 @@ dhcp6_makemessage(struct interface *ifp)
}
if (state->send->type != DHCP6_RELEASE) {
if (ifo->fqdn != FQDN_DISABLE) {
if (fqdn != FQDN_DISABLE) {
o = D6_NEXT_OPTION(o);
o->code = htons(D6_OPTION_FQDN);
p = D6_OPTION_DATA(o);
switch (ifo->fqdn) {
switch (fqdn) {
case FQDN_BOTH:
*p = D6_FQDN_BOTH;
break;
@ -2303,7 +2313,8 @@ dhcp6_start1(void *arg)
add_option_mask(ifo->requestmask6,
dhc->dhcp6_opt);
}
if (ifo->fqdn != FQDN_DISABLE)
if (ifo->fqdn != FQDN_DISABLE ||
ifo->options & DHCPCD_HOSTNAME)
add_option_mask(ifo->requestmask6, D6_OPTION_FQDN);
}

View File

@ -1,15 +1,9 @@
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
# Inform the DHCPv4 server of our hostname for DDNS.
# This has been superceded by the FQDN option below, but is included
# by default for servers which do not understand it.
# Inform the DHCP server of our hostname for DDNS.
hostname
# Inform the DHCP server of our hostname for DDNS
# and/or query for what it should be.
fqdn
# Use the hardware address of the interface for the Client ID.
#clientid
# or
@ -22,7 +16,7 @@ duid
option rapid_commit
# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name, fqdn
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers