Theo de Raadt <dera...@openbsd.org> wrote: > Thomas Bohl <openbsd-misc-518...@aloof.de> wrote: > > > Hello, > > > > > I suppose there is some argument that we should support hostname.MAC > > > files > > > > Maybe a function in netstart right before vifscreate could be enough > > to achieve this? I creates this diff, against stable for now though, > > as a test. > > > > Create a /etc/hostname.MAC file like you would create a > > /etc/hostname.if file. (MAC = lladdr as shown with ifconfig. Like > > /etc/hostname.08:00:27:14:26:0d) > > /etc/netstart than creates a symbolic link to the corresponding > > hostname.if. If there is a hostname.if file it is not overwritten. The > > rest works the same. > > > > > > --- netstart Tue Sep 27 19:39:43 2022 > > +++ netstart Tue Nov 22 03:39:49 2022 > > @@ -104,6 +104,21 @@ ifcreate() { > > fi > > } > > > > +# Symlink hostname.MAC to hostname.if. > > +# Existing hostname.if-file (no symlink) wins. > > +link_MAC_to_if() { > > + local _hn _mac _if > > + > > + for _hn in /etc/hostname.??:??:??:??:??:??; do > > + _mac=`echo $_hn | cut -c 15-31` > > + _if=`ifconfig | grep -B 1 $_mac | head -n 1 | awk -F ": " > > '{print $1}'`
Oh, except that using grep, head, or awk. That breaks NFS diskless machines, because they are in /usr, which may not be mounted yet. So this has to be done using shell features or commands in /bin and /sbin. You will see these interesting hacks in other parts of rc and netstart.