Subject: Re: DHCP with wifi (wi0)?
To: Andy Ruhl <acruhl@gmail.com>
From: Brian de Alwis <bsd@cs.ubc.ca>
List: netbsd-help
Date: 12/17/2006 16:54:23
Hi Andy.

On 2006.12.16 15:45:58 -0700, Andy Ruhl wrote:
> What is the proper way to setup DHCP for a wifi adapter? I can't find
> documents for this.

If you've done DHCP client configuration previously using dhclient
then you are pretty much set: the wireless stuff generally Just
Works.  Any of my configuration twiddles are simply to automate
processes at my various locations like authenticating to the network
and starting/stopping gaim and the like.

You haven't made it clear what exactly isn't working as you expected,
so it's a bit difficult to make recommendations.  Is your wireless
card binding to the wrong network (i.e., a different ssid than you
expected)? Are you getting no signal?  Dhclient isn't latching onto
anything?

If you're having difficulties getting an IP address, I'd suggest
just invoking dhclient from the command line and carefully observe
(and post here) what you see.  When I was first learning the wireless
stuff, I frequently did cycles of:

    # dhclient -r		# release configuration
    # dhclient

My /etc/rc.conf has:

    dhclient=YES
    dhclient_flags="-q -nw"

(-q = quiet, -nw = go daemon immediately)  I don't specify any
interfaces explicitly as I use dhclient for both my wired ethernet
and wireless adapter.  You can also specify the interface explicitly
in /etc/dhclient.conf.

My /etc/dhclient.conf contains the following, but really none of
it should be required.

    # so my firewall can use a nice identifier
    send dhcp-client-identifier "monolith";

    # ignore what the server sends: X11 clients can get messed up
    # if the host name changes underneath them
    supersede host-name "monolith";

    # these might be useless, but they can't hurt
    request subnet-mask, broadcast-address, routers,
	    domain-name, domain-name-servers;

I find it useful for debugging to dump the dhclient environment
provided by putting the following in /etc/dhclient-exit-hooks:

    set >/var/tmp/dhc-env.${interface}

You can also get much of the same information from /var/db/dhclient.leases.

It would have helped if you'd included the output from running the
different commands: `wiconfig wi0 -D', `ifconfig wi0', and the
contents of /var/db/dhclient.leases.

If your NetBSD machine will be moving around (i.e., a laptop), then
I'd recommend using wpa_supplicant(8), if your wifi card supports
it: you can configure multiple networks (= locations) with different
priorities and it will select the right one from the mix.
The NetBSD wiki has some recipes:

    http://wiki.netbsd.se/index.php/How_to_get_connected_using_WPA

Hope this helps somewhat.

Brian.

-- 
  Brian de Alwis | Software Practices Lab | UBC | http://www.cs.ubc.ca/~bsd/
      "Amusement to an observing mind is study." - Benjamin Disraeli