[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Running DHCP once wpa_supplicant associates with an AP?

On October 31, 2005 18:40, Joe Emenaker wrote:
> I think I've asked this before... either that or I searched and read a
> million other threads where they said "That can't be done, yet".
> So, I'm trying to find out if it can be done.... *yet*.
> All I want to do is have wpa_supplicant trigger a dhclient (or other
> dhcp client) for an interface when it associates with an AP. I've tried
> just putting the "iface eth1 inet dhcp" in /etc/network/interfaces, but
> that doesn't do it... and, last time I additionally put "auto eth1" in
> there, dhclient would try to run at boot time, before wpa_supplicant
> ran... and there'd be a long pause during the boot process while
> dhclient timed-out.
> It seems like something that so many people would want to do. I just
> can't figure out how.
> Any help?
> - Joe

I use ifplugd to bring my network devices up and down.  When wpa_supplicant 
associates with a wireless network, ifplugd detects that there is a link and 
thus can bring up the device.  It actually executes a script.  In the default 
setup, this is 

/etc/ifplugd/action.d/0-default <dev> up

which in turn calls

ifup <dev>

By default, this will apply the configuration
iface <dev> ... 
from /etc/network/interfaces.  So, if all you need is dhcp, here's a setup you 
can use:

INTERFACES="eth1"  # change to your device name
ARGS="--ignore-fail --delay-down=1 --delay-up=3 --ignore-retval --poll-time=1"

# This causes wpa_supplicant to be started at boot.  Change the driver (-D)
# and the interface suit your device.
OPTIONS="-w -c /etc/wpa_supplicant.conf -i eth1 -D ipw "

iface eth1 inet dhcp # again, change to your device's name
    pre-up /usr/sbin/wpa_cli reassociate

See if you can get this to work and post your results.  Using guessnet it's 
also possible to apply a different network configuration depending on the 
network where you associate.  For example, a static configuration at home and 
a dynamic (dhcp) configuration at school or work.  I can post more details 
about that if there's interest.


Reply to: