From owner-freebsd-arch Sun Apr 7 4: 0: 4 2002 Delivered-To: freebsd-arch@freebsd.org Received: from iguana.icir.org (iguana.icir.org [192.150.187.36]) by hub.freebsd.org (Postfix) with ESMTP id B20FF37B41C for ; Sun, 7 Apr 2002 03:59:41 -0700 (PDT) Received: (from rizzo@localhost) by iguana.icir.org (8.11.6/8.11.3) id g37Axf538216; Sun, 7 Apr 2002 03:59:41 -0700 (PDT) (envelope-from rizzo) Date: Sun, 7 Apr 2002 03:59:41 -0700 From: Luigi Rizzo To: arch@freebsd.org Subject: proposed code: automatic setting of hostname from MAC address Message-ID: <20020407035941.B37911@iguana.icir.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.23i Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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