* 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]) {
+ if (ifo->options & DHCPCD_HOSTNAME && ifo->hostname[0]) {
*p++ = DHO_HOSTNAME;
hp = strchr(ifo->hostname, '.');
if (hp)
memcpy(p, ifo->hostname, len);
p += len;
}
- if (ifo->fqdn != FQDN_DISABLE) {
+ if (ifo->fqdn != FQDN_DISABLE && ifo->hostname[0]) {
/* IETF DHC-FQDN option (81), RFC4702 */
*p++ = DHO_FQDN;
lp = p;
# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.
-# dhcpcd-run-hooks uses these options.
-option domain_name_servers, domain_name, domain_search, host_name
+# We normally want to inform the DHCP server of our hostname for DDNS.
+hostname
+# A list of options we should request from the DHCP server.
+option domain_name_servers, domain_name, domain_search, host_name
# Most distros have ntp support.
option ntp_servers
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 5, 2009
+.Dd January 28, 2009
.Dt DHCPCD.CONF 5 SMM
.Sh NAME
.Nm dhcpcd.conf
.It Ic fqdn Op none | ptr | both
none disables FQDN encoding, ptr just asks the DHCP server to update the PTR
record of the host in DNS whereas both also updates the A record.
-The current hostname or the hostname specified using the
-.Ic hostname
-option must be a FQDN.
.Nm dhcpcd
itself never does any DNS updates.
.Nm dhcpcd
strlcpy(ifo->script, arg, sizeof(ifo->script));
break;
case 'h':
- if (arg)
+ if (arg) {
s = parse_string(ifo->hostname,
HOSTNAME_MAX_LEN, arg);
- else
- s = 0;
- if (s == -1) {
- syslog(LOG_ERR, "hostname: %m");
- return -1;
- }
- if (s != 0 && ifo->hostname[0] == '.') {
- syslog(LOG_ERR, "hostname cannot begin with a .");
- return -1;
+ if (s == -1) {
+ syslog(LOG_ERR, "hostname: %m");
+ return -1;
+ }
+ if (s != 0 && ifo->hostname[0] == '.') {
+ syslog(LOG_ERR, "hostname cannot begin with .");
+ return -1;
+ }
+ ifo->hostname[s] = '\0';
}
- ifo->hostname[s] = '\0';
+ if (ifo->hostname[0] == '\0')
+ ifo->options &= ~DHCPCD_HOSTNAME;
+ else
+ ifo->options |= DHCPCD_HOSTNAME;
break;
case 'i':
if (arg)
ifo->timeout = DEFAULT_TIMEOUT;
ifo->reboot = DEFAULT_REBOOT;
ifo->metric = -1;
+ strlcpy(ifo->script, SCRIPT, sizeof(ifo->script));
gethostname(ifo->hostname, HOSTNAME_MAX_LEN);
/* Ensure that the hostname is NULL terminated */
ifo->hostname[HOSTNAME_MAX_LEN] = '\0';
if (strcmp(ifo->hostname, "(none)") == 0 ||
strcmp(ifo->hostname, "localhost") == 0)
ifo->hostname[0] = '\0';
- strlcpy(ifo->script, SCRIPT, sizeof(ifo->script));
ifo->vendorclassid[0] = snprintf((char *)ifo->vendorclassid + 1,
- VENDORCLASSID_MAX_LEN,
- "%s %s", PACKAGE, VERSION);
+ VENDORCLASSID_MAX_LEN,
+ "%s %s", PACKAGE, VERSION);
/* Parse our options file */
f = fopen(file ? file : CONFIG, "r");
if (line && *line) {
p = line + strlen(line) - 1;
while (p != line &&
- (*p == ' ' || *p == '\t') &&
- *(p - 1) != '\\')
+ (*p == ' ' || *p == '\t') &&
+ *(p - 1) != '\\')
*p-- = '\0';
}
/* Start of an interface block, skip if not ours */