Aug 272012
 

I recently had some issues with the WiFi on one of my computers. The WiFi network it normally connects to was down and it wouldn’t connect to another network. This also happened on my Raspberry Pi recently, so I did something similar to get it to connect.
Using wpa_cli, I got the network to connect to make sure that all the configuration parameters were correct. I then created the configuration file that I needed for automatic connection.

To connect manually, you need to first start up wpa_cli. This assumes that wpa_supplicant is already running, which it should be in most cases. If it’s not, you will see an error when you start wpa_cli.

Otherwise, once you’re in wpa_cli, it will show a prompt similar to this

Selected interface 'wlan0'

Interactive mode

>

Using the scan and scan_results command, you can scan for the networks and see some basic information

> scan
OK
<2>CTRL-EVENT-SCAN-RESULTS
> scan_results
bssid / frequency / signal level / flags / ssid
00:55:ab:25:ac:5a 2462 -71 [WPA2-PSK-CCMP][ESS] WLAN-Network
00:11:99:51:ba:f0 2437 -64 [WPA2-PSK-CCMP][ESS] WLAN-Network2
>

In the above scan results, you can see the 2 networks that the computer can pick up, the frequencies / channel that they are broadcasting on, the signal strength, the security type, and network name. Both of these networks are using WPA2 with a Pre-Shared Key.

To connect to one of them, we need to first create a network.

> add_network

This will output a number, which is the network ID.

> add_network
0

This will create an empty network ready for us to configure it.
Next up, we need to set the SSID and PSK for the network.

set_network 0 ssid "WLAN-Network"
set_network 0 psk "SupahSecretPassphrase"

Once these parameters are entered, wpa_cli should show the client trying to connect straight away.
When it tries to connect, it should show something like this

> <2>Trying to authenticate with 00:55:ab:25:ac:5a (SSID='WLAN-Network' freq=2437 MHz)
> <2>Trying to associate with 00:55:ab:25:ac:5a (SSID='WLAN-Network' freq=2437 MHz)
> <2>Associated with 00:55:ab:25:ac:5a
> <2>WPA: Key negotiation completed with 00:55:ab:25:ac:5a [PTK=CCMP GTK=CCMP]
> <2>CTRL-EVENT-CONNECTED - Connection to 00:55:ab:25:ac:5a completed (reauth) [id=0 id_str=]

Once the wireless has connected, it should automatically get an IP address.
If it doesn’t you can run the dhclient command to force it to get an IP address via DHCP, or edit /etc/network/interfaces to set a static IP address for the wireless network interface.

Hopefully this helps someone out there !

Share
Aug 102012
 

QuickLinks
Part 1 – How to create a Wireless Network On Your RPi
Part 3 – How to make your RPi into a Router

In this part, we will turn the Raspberry Pi into a Wireless Access point.
All it will do is forward packets from the WiFi adapter to ethernet and vice versa. It will allow you to access your network via WiFi without needing a WiFi router.

To do this, we need to bridge the ethernet and wifi connections, and tell hostapd that we are now using a bridge connection.
In /etc/hostapd/hostapd.conf, we need to add the following line.

bridge=br0

Add the following lines into /etc/network/interfaces to define the bridge connection.

#auto br0
iface br0 inet dhcp
bridge_ports eth0 wlan0
pre-up ifconfig eth0 0.0.0.0 up
pre-up ifconfig wlan0 0.0.0.0 up
pre-up brctl addbr br0
pre-up brctl addif br0 eth0
post-down ifconfig wlan0 0.0.0.0 down
post-down ifconfig eth0 0.0.0.0 down
post-down brctl delif br0 eth0
post-down brctl delbr br0

Notice the “auto br0” is commented out. This is so the bridge does not come up automatically, as once the bridge is up, you will not be able to remotely access the Raspberry Pi until the bridge is brought down or until the bridge gets an IP address.

Once the lines are in /etc/network/interfaces, you can type in ifup br0 as root to bring up the bridge. If you are ssh’ed into the Pi, this will drop your connection.
Once it’s up, the Raspberry Pi will forward anything from the WiFi to ethernet and vice versa.

This let’s the Raspberry Pi act as a Wireless Access Point without any sort of routing. On a WiFi device, you will be able to connect to RaspAP, and it will act is if it was on the network, i.e. it will get an IP address from your normal router.


If you have found this post useful, please consider donating by pressing on the button below. Donating will help keep this site up and running ๐Ÿ™‚




Share
May 062012
 

I’ve recently had an issue with one of my boxes, where the WiFi interface will not let any new connections in unless a connection out is established first. The connection can be established by anything, a ping, a ssh connection or anything.
I can’t track down what’s causing it. It’s using a RTL8187 USB stick with an external antenna with a 2.6.39 custom kernel. The same thing happens on a 3.3 kernel however.

iwconfig is reporting that power management is off, and I have disabled wireless power management in the kernel also.
Is there anything else that anyone can think of ?
Any more information needed to help me troubleshoot this ?

Share