Manually connecting to a wireless WPA-protected network.

niflheim

New Member

Reaction score: 7
Messages: 3

Hello everyone,
I am completely new to both FreeBSD and this forum so please bear with me. I believe I am following the forum rules and guidelines, but please forgive me if I'm doing something wrong.

I have successfully installed FreeBSD-9.0-STABLE on my ASUS 1225B laptop and I have created the kernel modules (is it "modules" or "drivers"?) for my Broadcom wireless network adapter (BCM4313) using ndisgen. In order to use these modules I placed them in the /boot/modules/ directory, and created the following /etc/rc.d script (I first tried to load the modules from /boot/loader.conf, but doing so the kernel wouldn't boot at all):
Code:
#!/bin/sh

# PROVIDE: bcm4313
# REQUIRE: NETWORKING
# BEFORE: LOGIN
# KEYWORD: nojail

. /etc/rc.subr

name="bcm4313"
start_cmd="${name}_start"
stop_cmd=":"

bcm4313_start()
{
   echo "Loading Broadcom BCM4313 NDIS kernel modules."
   kldload bcm43xx64.cat.ko
   kldload bcmwlcoi64.dll.ko
   kldload bcmwl564_sys.ko
}

load_rc_config $name
run_rc_command "$1"
I then added the following lines to /etc/rc.conf:
Code:
wlans_ndis0="wlan0"
ifconfig_wlan0="WPA SYNCDHCP"
And the following lines to /etc/wpa_supplicant.conf:
Code:
network={
   ssid="<router name>"
   psk="<router wpa key>"
}
Now, by doing this I had a fully established wireless connection as soon as I had logged in to FreeBSD (I am saying "had" because I have since reinstalled the whole system; I have recreated the /etc/rc.conf and /etc/wpa_supplicant.conf files exactly as they were, however I don't remember exactly how I wrote the /etc/rc.d script, and I believe that the modules are being loaded a little too soon or too late, because I now end up with a kernel panic a couple of seconds after the login screen appears, but this is not why I am writing this thread).

My question is; since I am running the system on a laptop that I will carry with me, I may want to connect to a wireless WPA-protected network on the spot, without having to reboot the system. How exactly do I do that? I assume that no matter what I will always have to edit /etc/wpa_supplicant.conf to match the network I am trying to connect to, but other than that, how? This is what I have tried so far:
Code:
# ifconfig wlan0 create wlandev ndis0
# ifconfig wlan0 up
# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf
# dhclient wlan0
The first two ifconfig commands are successful, I am able to scan for and find wireless networks. However I seem to be missing something, because the wpa_supplicant command doesn't seem to work; I expect it to finish, and allow me to continue writing commands to the terminal, which it doesn't. Because of that I tried to run it like this:# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B
I now expect wpa_supplicant to have associated wlan0 with the router, but it hasn't. Here is the output of:# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -dd
Code:
Initializing interface 'wlan0' conf '/etc/wpa_supplicant.conf' driver 'default' ctrl_interface 'N/A' bridge 'N/A
Configuration file '/etc/wpa_supplicant.conf' -> '/etc/wpa_supplicant.conf'
Reading configuration file '/etc/wpa_supplicant.conf'
Line: 1 - start of a new network block
ssid - hexdump_ascii(len=7):
   4e 45 54 47 45 41 52
PSK (ASCII passphrase) - hexdump_ascii(len=13): [REMOVED]
PSK (from passphrase) - hexdump(len=32): [REMOVED]
Priority group 0
   id=0 ssid='NETGEAR'
Own MAC address: 00:08:ca:ef:f4:22
wpa_driver_bsd_del_key: keyidx=0
wpa_driver_bsd_del_key: keyidx=1
wpa_driver_bsd_del_key: keyidx=2
wpa_driver_bsd_set*countermeasures: enabled=0
RSN: flushing PMKID list in the driver
Setting scan request: 0 sec 100000 usec
EAPOL: SUPP_PAE entering state DISCONNECTED
EAPOL: Supplicant port status: Unauthorized
EAPOL: KEY_RX entering state INITIALIZE
EAP: EAP entering state DISABLED
EAPOL: Supplicant port status: Unauthorized
EAPOL: Supplicant port status: Unauthorized
Added interface wlan0
State: DISCONNECTED -> SCANNING
Starting AP scan for wildcard SSID
EAPOL: disable timer tick
EAPOL: Supplicant port status: Unauthorized
After this output it just hangs, and I have to press CTRL-C to force it to stop. I would really appreciate all the help I can get. I feel like I've been staring myself blind at all the man pages etc.

Sorry for a long post and thanks in advance.
 
OP
N

niflheim

New Member

Reaction score: 7
Messages: 3

I just stumbled across the answer myself. Apparently there are more options for wpa_supplicant than mentioned in the man pages; I found what I needed in the /etc/rc.d/wpa_supplicant script. My wlan0 is now associating with the network and I can run dhclient perfectly fine. Here is the complete command :# wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf -D ndis.

Cheers! ;)
 

cpm@

Moderator
Staff member
Moderator
Developer

Reaction score: 947
Messages: 2,140

niflheim said:
I just stumbled across the answer myself. Apparently there are more options for wpa_supplicant than mentioned in the man pages; I found what I needed in the /etc/rc.d/wpa_supplicant script. My wlan0 is now associating with the network and I can run dhclient perfectly fine. Here is the complete command :# wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf -D ndis.

Cheers! ;)
You forgot "-B" (daemonize) option to starting manually.

If you prefer to start wpa_supplicant when the system booted, add this line in /etc/rc.conf
Code:
wpa_supplicant_enable="YES"
Then you don't need type above commands.
 
  • Thanks
Reactions: 0mp
Top