Subject: Re: Getting laptop to auto-dhclient
To: Steven M. Bellovin <smb@research.att.com>
From: Brian Grayson (home) <bgrayson@austin.rr.com>
List: netbsd-users
Date: 10/11/2003 16:45:21
On Sat, Oct 11, 2003 at 01:44:26PM -0400, Steven M. Bellovin wrote:
> In message <17236.1065892334@munnari.OZ.AU>, Robert Elz writes:
> >    Date:        Fri, 10 Oct 2003 23:49:27 -0500
> >    From:        "Brian Grayson \(home\)" <bgrayson@austin.rr.com>
> >    Message-ID:  <20031010234927.A1368@cs24279-4.austin.rr.com>
> >
> >  |   Is it possible for me to set up my laptop so that when I plug in
> >  | an Ethernet cable, it automatically invokes a script for me (to run
> >  | dhclient, etc.)?
> >
> >Unfortunately, not yet on NetBSD, this is something that is badly
> >needed, and one day I might just get irritated enough...
> > 
> >  |   Or is my best bet to have a shell script continue doing an ifconfig and
> >  | wait for the status to change from no-carrier to active, and sleep for 15
> >  | seconds between checks?
> >
> >If you're willing to wait a bit, just leave dhclient running on the interface
> >from when you boot - it will just keep on trying (not very frequently though)
> >until it succeeds.   Unfortunately, if you then get a long lease (comparativel
> >y
> >long compared to how long you're actually connected), it won't notice when you
> >disconnect from one LAN and plug into another.
> >
> >And this also doesn't work if the interface doesn't exist when you boot (as in
> >a plug in card or device of some kind).
> >
> 
> There's supposed to be an interface to dhclient that should make that 
> easier, but the documentation is sparse (arguably, non-existent) on how 
> to make it work.  That doesn't solve the trigger problem -- my current 
> "solution" is to restart dhclient from /etc/apm/resume -- but it should 
> help with adding cards.

  My personal situation is that my laptop will be docked and happy,
and then I'll undock it and go to a conference room and plug the
network cable in.  Sometimes I'm projecting my laptop for all to see,
so waiting a minute or more for cron to kick in is unacceptable. 
Currently, I just log in as root and kill dhclient and then start it up
again.  But that just seems so '90s.  :)

  It seems like the Right Thing is for the kernel to provide some kind
of notification, whether it's by writing to a socket that a daemon
is blocked on, or something like that.  Does NetBSD currently have
such a mechanism for anything?  It seems like it's sort of similar to
/proc and /kern (fd with one end handled by the kernel), although
they don't usually block.  But I'm no kernel hacker!  (It shows!)

  For now, I may do something like take ifconfig and hack it to just
check status every few seconds, and when it detects a delta, have it
fire off some script to DTRT.

  Brian