Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 May 2009 08:55:32 +0100
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        Pieter Donche <Pieter.Donche@ua.ac.be>
Cc:        "mail.list freebsd-questions" <freebsd-questions@freebsd.org>
Subject:   Re: isc-dhcpd server, HOSTNAME
Message-ID:  <4A068874.8030408@infracaninophile.co.uk>
In-Reply-To: <alpine.BSF.2.00.0905071637270.45332@macos.cmi.ua.ac.be>
References:  <alpine.BSF.2.00.0905071637270.45332@macos.cmi.ua.ac.be>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigA239BF2CA9A45A6903F51EB1
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

Pieter Donche wrote:
> FreeBSD7 with isc-dhcp30-server.
> It hands out an IP address, OK,
> but the BASH environment variable HOSTNAME is not set. Why?
>=20
> (A DNS server is active on the network and can succesfully be queried=20
> from a FreeBSD bash command (nslookup or host) to see the hostname=20
> associated with the IP-address)

Hostname is not one of the parameters usually requested from a DHCP serve=
r
by a Unix machine.  In fact, it's normally the other way round: the clien=
t
tells the DHCP server what it's hostname is and the DHCP server can then
inject an A record into the DNS dynamically.

However it is possible to operate in the way you want.  To tell the dhcp
server to look up names from the DNS based on the address supplied to a
host, search for the description of the 'get-lease-hostnames' flag in
the dhcpd.conf(5) man page.

To tell dhcp clients to fetch their hostname from DHCP, you need to add i=
t
to a 'request' or 'require' block in dhclient.conf -- see dhclient.conf(5=
).

It's been a long time since I ran a setup anything like that, so I cannot=

recall if that was all that was required, or if it was also necessary to
write a small dhclient-script(8) to actually set the hostname.=20

Another alternative is to use a dhclient-script to take the IP number
allocated by the DHCP server, look up the corresponding address and then
set that as the hostname.

The bash HOSTNAME environment variable will be set from the output of the=

hostname(1) command, which is usually set from the hostname variable in
/etc/rc.conf or from the output of '/bin/kenv dhcp.host-name' if that=20
is set. Otherwise it uses a default hostname of 'amnesiac'.=20

	Cheers,

	Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
                                                  Kent, CT11 9PW


--------------enigA239BF2CA9A45A6903F51EB1
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEAREIAAYFAkoGiHoACgkQ8Mjk52CukIxgGACcCWDzeDfvKhmalRbMzhQrTZF+
cLAAn1uzX45+gZW4dua59kw8+pLlPim+
=mAPN
-----END PGP SIGNATURE-----

--------------enigA239BF2CA9A45A6903F51EB1--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A068874.8030408>