96 lines
2.8 KiB
Plaintext
96 lines
2.8 KiB
Plaintext
--- client/dhclient.8
|
|
+++ client/dhclient.8 2008/09/08 15:19:13
|
|
@@ -36,6 +36,9 @@
|
|
.I port
|
|
]
|
|
[
|
|
+.B -H hostname
|
|
+]
|
|
+[
|
|
.B -d
|
|
]
|
|
[
|
|
@@ -172,6 +175,11 @@
|
|
transmit on, the client will also use a different destination port -
|
|
one less than the specified port.
|
|
.PP
|
|
+The
|
|
+.B -H
|
|
+flag may be used to specify a client hostname that should be sent to
|
|
+the DHCP server.
|
|
+.PP
|
|
The DHCP client normally transmits any protocol messages it sends
|
|
before acquiring an IP address to, 255.255.255.255, the IP limited
|
|
broadcast address. For debugging purposes, it may be useful to have
|
|
--- client/dhclient.c
|
|
+++ client/dhclient.c 2008/09/08 15:17:50
|
|
@@ -100,6 +100,7 @@ int main (argc, argv, envp)
|
|
int no_dhclient_db = 0;
|
|
int no_dhclient_pid = 0;
|
|
int no_dhclient_script = 0;
|
|
+ char *dhclient_hostname = NULL;
|
|
char *s;
|
|
|
|
/* Make sure that file descriptors 0 (stdin), 1, (stdout), and
|
|
@@ -189,6 +190,15 @@ int main (argc, argv, envp)
|
|
if (++i == argc)
|
|
usage ();
|
|
relay = argv [i];
|
|
+ } else if (!strcmp (argv [i], "-H")) {
|
|
+ if (++i == argc || !argv[i] || *(argv[i]) == '\0')
|
|
+ usage ();
|
|
+ if (strlen (argv[i]) > HOST_NAME_MAX) {
|
|
+ log_error("-H option host-name string \"%s\" is too long:"
|
|
+ "maximum length is %d characters", argv[i], HOST_NAME_MAX);
|
|
+ exit(1);
|
|
+ }
|
|
+ dhclient_hostname = argv [i];
|
|
} else if (!strcmp (argv [i], "-nw")) {
|
|
nowait = 1;
|
|
} else if (!strcmp (argv [i], "-n")) {
|
|
@@ -345,6 +355,32 @@ int main (argc, argv, envp)
|
|
/* Parse the dhclient.conf file. */
|
|
read_client_conf ();
|
|
|
|
+ /* If the user specified a hostname, send it here and now */
|
|
+ if ((dhclient_hostname != NULL) && (*dhclient_hostname != '\0') ) {
|
|
+ struct parse *cfile = NULL;
|
|
+ char buf[HOST_NAME_MAX + 40];
|
|
+ int len;
|
|
+
|
|
+ snprintf (buf, sizeof(buf), "send host-name \"%s\";", dhclient_hostname);
|
|
+ len = strlen(buf);
|
|
+
|
|
+ status = new_parse (&cfile, -1, buf, len, "host-name option", 0);
|
|
+ if (status != ISC_R_SUCCESS)
|
|
+ log_fatal ("Cannot parse send host-name statement!");
|
|
+
|
|
+ for (;;) {
|
|
+ const char *val = NULL;
|
|
+ int token;
|
|
+
|
|
+ token = peek_token (&val, (unsigned *)0, cfile);
|
|
+ if (token == END_OF_FILE)
|
|
+ break;
|
|
+
|
|
+ parse_client_statement (cfile, NULL, &top_level_config);
|
|
+ }
|
|
+ end_parse (&cfile);
|
|
+ }
|
|
+
|
|
/* Parse the lease database. */
|
|
read_client_leases ();
|
|
|
|
@@ -483,9 +519,9 @@ static void usage ()
|
|
log_info (arr);
|
|
log_info (url);
|
|
|
|
- log_error ("Usage: dhclient [-1dqrx] [-nw] [-p <port>] %s",
|
|
+ log_error ("Usage: dhclient [-1dqrx] [-nw] [-H <hostname>] [-p <port>] %s",
|
|
"[-s server]");
|
|
- log_error (" [-cf config-file] [-lf lease-file]%s",
|
|
+ log_error (" [-cf config-file] [-lf lease-file] %s",
|
|
"[-pf pid-file] [-e VAR=val]");
|
|
log_fatal (" [-sf script-file] [interface]");
|
|
}
|