iwconfig... or not
This wasn't the first time I've unsuccessfully tried to connect to an open wireless network from the command line using iwconfig (which should be a simple task) and this time I was determined to find the solution. In this case I was running Knoppix, but I've had the same problem on Debian and [XK]?Ubuntu as well.
I tried...
iwconfig wlan0 essid rasberry
iwconfig wlan0 essid rasberry mode Managed
iwconfig wlan0 essid rasberry mode Managed chan 1
iwconfig wlan0 essid rasberry mode Managed chan 1 ap 00:01:02:03:04:05
-etc-
dhclient wlan0
...but no matter what, I couldn't get an IP or even see any DHCP traffic from my device at the router. Furthermore iwconfig wlan0 would consistently report that I was not associated.
ˇFRUSTRATING!
Lots of searches turned up little more than inapplicable solutions and unanswered questions.
So I checked dmesg to see if there were any errors being reported and found something like this:
deauthenticating by local choice, reason=3
OK... that's not MY choice, so WTF? Turns out that even though I started knoppix in runlevel 2, network-manager was running, which had wpa_supplicant running, (even though I was not connected to a network, have no predefined network profiles, am not running any network-manager clients, etc) and as I see it, wpa_supplicant was fighting with me for control of the wlan adapter config. So that was helpful... NOT!
I killed wpa_supplicant but it was immediately respawned by network-manager so I had to stop network-manager and then kill wpa_supplicant, and THEN, FINALLY, I was able to connect to the network with a simple:
iwconfig wlan0 essid rasberry; dhclient wlan0

