Date: Mon, 20 Mar 2006 18:22:58 +0100 (CET) From: Frank Behrens <frank@pinky.sax.de> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/94743: dhclient(8) should send hostname [patch] Message-ID: <200603201722.k2KHMwuD008128@moon.behrens> Resent-Message-ID: <200603201730.k2KHUHw9012899@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 94743 >Category: bin >Synopsis: dhclient(8) should send hostname [patch] >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Mar 20 17:30:16 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Frank Behrens >Release: FreeBSD 6.1-PRERELEASE-200602270917 i386 >Organization: >Environment: >Description: dhclient(8) should send the clients hostname to DHCP server. In that case the DHCP server can make dynamic updates on a DNS server. This simplifies the setup of DHCP client networks. With this change a default FreeBSD installation, where the network adapter is configured by DHCP, is immediately visible in DNS with forward and reverse lookups for the given host name. It is however required that DHCP and DNS server are setup accordingly. The ability to overwrite the hostname with another value in dhclient.conf(5) is not affected. A short investigation shows the behaviour of default operating system installations (tcpdump): Knoppix 5.0 as Debain based Linux with pump(8) as DHCP client: Client Ethernet Address: 00:0c:29:c6:cb:9b Vendor-rfc1048: DHCP:REQUEST CID:[ether]00:0c:29:c6:cb:9b MSZ:548 PR:SM+DG+NS+DN+BR+HN+LOG+LPR+NTP+XFS+XDM+MTU HN:"Knoppix^@" LT:43200 SID:192.168.99.10 RQ:192.168.99.70 Windows XP SP2 (Windows-98 not traced, but same behaviour): Client Ethernet Address: 00:10:dc:31:73:47 Vendor-rfc1048: DHCP:REQUEST CID:[ether]00:10:dc:31:73:47 RQ:192.168.99.69 SID:192.168.99.10 HN:"myhost" VC:"MSFT 5.0" PR:SM+DN+DG+NS+WNS+WNT+WSC+RD+SR+T249+VO NetBSD, FreeBSD 4.2, FreeBSD 6.x: Client Ethernet Address: 00:0c:29:c6:cb:9b Vendor-rfc1048: DHCP:REQUEST RQ:192.168.99.70 PR:SM+BR+TZ+DG+DN+NS+HN FreeBSD 6.x with patch: Client Ethernet Address: 00:0c:29:c6:cb:9b Vendor-rfc1048: DHCP:REQUEST RQ:192.168.99.70 HN:"myhost" PR:SM+BR+TZ+DG+DN+NS+HN FreeBSD 6.x with patch and SEND_CLIENT_IDENTIFIER: Client Ethernet Address: 00:0c:29:c6:cb:9b Vendor-rfc1048: DHCP:REQUEST RQ:192.168.99.65 CID:[ether]00:0c:29:c6:cb:9b HN:"myhost" PR:SM+BR+TZ+DG+DN+NS+HN In the patch is a not activated section "SEND_CLIENT_IDENTIFIER". If enabled dhclient sends a client identifier compatible with RFC2132,9.14. This identifier is always sent from Windows clients and can be switched on via command line argument on Linux pump(8). It may be activated to provide better compatibility with Windows clients, but the author can not rate the advantages. proposed MFC: after 6.1R >How-To-Repeat: >Fix: Index: dhclient.c =================================================================== RCS file: /data/freebsd/src/sbin/dhclient/dhclient.c,v retrieving revision 1.6.2.4 diff -u -r1.6.2.4 dhclient.c --- dhclient.c 24 Jan 2006 05:59:27 -0000 1.6.2.4 +++ dhclient.c 20 Mar 2006 16:38:24 -0000 @@ -54,6 +54,7 @@ */ #include <sys/cdefs.h> +#include <unistd.h> __FBSDID("$FreeBSD: src/sbin/dhclient/dhclient.c,v 1.6.2.4 2006/01/24 05:59:27 brooks Exp $"); #include "dhcpd.h" @@ -1553,6 +1554,40 @@ ip->client->config->send_options[i].len; options[i]->timeout = 0xFFFFFFFF; } + + /* send host name if not set via config file. */ + char hostname[_POSIX_HOST_NAME_MAX+1]; + if (!options[DHO_HOST_NAME]) { + if (gethostname(hostname, sizeof(hostname)) == 0) { + size_t len; + char* posDot = strchr(hostname, '.'); + if (posDot != NULL) + len = posDot - hostname; + else + len = strlen(hostname); + options[DHO_HOST_NAME] = &option_elements[DHO_HOST_NAME]; + options[DHO_HOST_NAME]->value = hostname; + options[DHO_HOST_NAME]->len = len; + options[DHO_HOST_NAME]->buf_size = len; + options[DHO_HOST_NAME]->timeout = 0xFFFFFFFF; + } + } + +#ifdef SEND_CLIENT_IDENTIFIER + /* set unique client identifier */ + char client_ident[sizeof(struct hardware)]; + if (!options[DHO_DHCP_CLIENT_IDENTIFIER]) { + int hwlen = (ip->hw_address.hlen < sizeof(client_ident)-1) ? + ip->hw_address.hlen : sizeof(client_ident)-1; + client_ident[0] = ip->hw_address.htype; + memcpy(&client_ident[1], ip->hw_address.haddr, hwlen); + options[DHO_DHCP_CLIENT_IDENTIFIER] = &option_elements[DHO_DHCP_CLIENT_IDENTIFIER]; + options[DHO_DHCP_CLIENT_IDENTIFIER]->value = client_ident; + options[DHO_DHCP_CLIENT_IDENTIFIER]->len = hwlen+1; + options[DHO_DHCP_CLIENT_IDENTIFIER]->buf_size = hwlen+1; + options[DHO_DHCP_CLIENT_IDENTIFIER]->timeout = 0xFFFFFFFF; + } +#endif /* Set up the option buffer... */ ip->client->packet_length = cons_options(NULL, &ip->client->packet, 0, >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603201722.k2KHMwuD008128>