Skip to contentSkip to conversation

ipconfig: send host-name in DHCP requests

PATCH Applied Wu Fengguang 3 participants 5 messages May 31, 2010 – Jun 3, 2010

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipconfig: send host-name in DHCP requests

Normally dhclient can be configured to send the "host-name" option in DHCP requests to update the client's DNS record. However for an NFSROOT system, dhclient shall never be called (which may change the IP addr and therefore lose your root NFS mount connection).

So enable updating the DNS record with kernel parameter

	ip=::::$HOST_NAME::dhcp
---
 net/ipv4/ipconfig.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
net/ipv4/ipconfig.c +7 -0
index 067ce9e..db54343 100644
@@ -665,6 +665,13 @@ ic_dhcp_init_options(u8 *options)
 		memcpy(e, ic_req_params, sizeof(ic_req_params));
 		e += sizeof(ic_req_params);
 
+		if (ic_host_name_set) {
+			*e++ = 12;	/* host-name */
+			len = strlen(utsname()->nodename);
+			*e++ = len;
+			memcpy(e, utsname()->nodename, len);
+			e += len;
+		}
 		if (*vendor_class_identifier) {
 			printk(KERN_INFO "DHCP: sending class identifier \"%s\"\n",
 			       vendor_class_identifier);
Signature · 1 line
1.6.6
maintainer Applied
#1 lore raw

From: Wu Fengguang <[email protected]>
Date: Mon, 31 May 2010 11:19:53 +0800

Quoted 10 lines

Normally dhclient can be configured to send the "host-name" option in DHCP requests to update the client's DNS record. However for an NFSROOT system, dhclient shall never be called (which may change the IP addr and therefore lose your root NFS mount connection).

So enable updating the DNS record with kernel parameter

	ip=::::$HOST_NAME::dhcp

Applied, thanks.

#2 lore raw
Quoted 8 lines · David Miller

From: Wu Fengguang <[email protected]>
Date: Mon, 31 May 2010 11:19:53 +0800

Quoted 5 lines

Normally dhclient can be configured to send the "host-name" option in DHCP requests to update the client's DNS record. However for an NFSROOT system, dhclient shall never be called (which may change the IP addr and therefore lose your root NFS mount connection).

Quoted 7 lines
Quoted 5 lines

So enable updating the DNS record with kernel parameter

	ip=::::$HOST_NAME::dhcp

Applied, thanks.

Small nit: Fengguang, please document the new option in Documentation/kernel-parameters.txt That could be done in a follow-on patch.

-Andi

Quoted 1 line
Signature · 1 line
[email protected] -- Speaking for myself only.
#3 lore raw

PATCH 1/1 ipconfig: document DHCP hostname and DNS record

Quoted 11 lines · Andi Kleen
Quoted 10 lines · David Miller

From: Wu Fengguang <[email protected]>
Date: Mon, 31 May 2010 11:19:53 +0800

Quoted 7 lines

Normally dhclient can be configured to send the "host-name" option in DHCP requests to update the client's DNS record. However for an NFSROOT system, dhclient shall never be called (which may change the IP addr and therefore lose your root NFS mount connection).

So enable updating the DNS record with kernel parameter

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
	ip=::::$HOST_NAME::dhcp

Applied, thanks.

Small nit: Fengguang, please document the new option in Documentation/kernel-parameters.txt That could be done in a follow-on patch.

Good suggestion! Here is the document update.

Thanks,
Fengguang
---
ipconfig: document DHCP hostname and DNS record

Now it's possible to update the DNS record for $HOST_NAME with

	ip=::::$HOST_NAME::dhcp
---
 Documentation/filesystems/nfs/nfsroot.txt |    2 ++
 1 file changed, 2 insertions(+)
Documentation/filesystems/nfs/nfsroot.txt +2 -0
@@ -124,6 +124,8 @@ ip=<client-ip>:<server-ip>:<gw-ip>:<netm
 
   <hostname>	Name of the client. May be supplied by autoconfiguration,
   		but its absence will not trigger autoconfiguration.
+		If specified and DHCP is used, the user provided hostname will
+		be carried in the DHCP request to hopefully update DNS record.
 
   		Default: Client IP address is used in ASCII notation.