Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Apr 2002 03:59:41 -0700
From:      Luigi Rizzo <rizzo@icir.org>
To:        arch@freebsd.org
Subject:   proposed code: automatic setting of hostname from MAC address
Message-ID:  <20020407035941.B37911@iguana.icir.org>

next in thread | raw e-mail | index | archive | help
Hi,
as part of the PicoBSD "rc" scripts, there is some code which
determines the hostname (and IP) of a box from the MAC address
of the first ethernet interface, using /etc/hosts
as a database of known machines. The relevant code is in

	src/release/picobsd/floppy.tree/etc/rc.conf.defaults

I was wondering whether, with the necessary modifications (see
NOTES), there is interest in merging this feature into the standard
startup scripts. For PicoBSD the usefulness is obvious -- being
images often resident on removable media, this lets you use the
exact same image for different machines.

I have other setups where this can be useful, e.g. I often use disks
on removable frames and move them back and forth across different
machines; or, for some centrally-administered configurations, this
mechanism can also be very useful, as it permits to centralise the
configuration to one or two files (rc.conf plus the database of
MAC<->hostnames).

Comments ?

	cheers
	luigi

NOTES

1. Possible modifications include fetching the MAC-hostname
   info from /etc/ethers instead of /etc/hosts, and enabling
   this feature only if explicitly invoked from rc.conf
   (i.e. put an 'auto_set_hostname()' call in rc.conf in place
   of 'hostname=foo.bar' and make sure the procedure is run
   only once even if rc.conf is sourced multiple times).

2. This code becomes mostly useful if we use, in rc.conf,
   a case statement to set the configuration:

	# rc.conf
	auto_set_hostname()
	...
	case "${hostname} in
	*.at.work)
		defaultrouter="5.6.7.8"
		sendmail_enable="YES"
		;;
	*.at.home)
		defaultrouter="1.2.3.4"
		;;
	esac
	...

3. Another thing (again already implemented in the PicoBSD scripts) that
   helps a lot in managing multiple configurations is to have
   a mechanism to overwrite, from the rc* scripts, some basic
   (and short) configuration files such as resolv.conf, host.conf,
   and maybe fstab. Basically you set shell variables in rc.conf to provide
   the content for these files, and at some early point in /etc/rc
   these variable are used to update the corresponding files in /etc

   
   
   This seems to be deprecated by the current structure of rc.conf,
   though it can have some good uses.
--------------------------------

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




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