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.
}
}
- /* 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;
*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 */
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) {
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;
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);
}
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;
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);
}
# 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
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