Saturday 23 November 2013

Raspberry pi setting up wireless


Wireless on a raspberry pi. Written while is was setting up a wireless motion camera. I am a network guy so as a raspberry pi starter; I am on some familiar territory. First thing to do after you plugged in the the wireless dongle, is to check if it is being recognized. To do this issue:


lsusb

pi@raspberrypi ~ $ lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter

As you can see in the output above, my wireless dongle has the Ralink 5370 chipset in it. The chipset is important, more important than the dongle's type. This because manufacturers sometimes change chipsets, without proper notice. 
If you wireless dongle is not get recognized  don't continue on yet, and sort that out first. Try a powered hub for instance. If you are already using a powered hub, try another computer to make sure it does work (particularly when its a new dongle).

DRIVERS/MODULES

I decided to check the compatibility of my dongle (Deal Extreme, special cheap peace of %^& for a cheap arse);

http://elinux.org/RPi_USB_Wi-Fi_Adapters


Now check the modules that are loaded. For this, issue:

lsmod 

In my case this gave me the following output:

pi@raspberrypi ~ $ lsmod
Module                  Size  Used by
snd_bcm2835            16432  0
snd_pcm                77728  1 snd_bcm2835
snd_seq                53482  0
snd_timer              20110  2 snd_pcm,snd_seq
snd_seq_device          6462  1 snd_seq
snd                    58744  5 snd_bcm2835,snd_timer,snd_pcm,snd_seq,snd_seq_device
snd_page_alloc          5169  1 snd_pcm
arc4                    1684  2
rt2800usb              14948  0
rt2800lib              55359  1 rt2800usb
crc_ccitt               1530  1 rt2800lib
rt2x00usb              11240  1 rt2800usb
rt2x00lib              42342  3 rt2x00usb,rt2800lib,rt2800usb
mac80211              273979  3 rt2x00lib,rt2x00usb,rt2800lib
cfg80211              184390  2 mac80211,rt2x00lib
rfkill                 18298  2 cfg80211
leds_gpio               2243  0

led_class               3570  2 leds_gpio,rt2x00lib

Because the rt2800usb module was loaded, I decided to configure the interface and see if it would associate with my access point. 

CONFIGURE INTERFACE

Once you have ascertained that the stick is recognised and the module is loaded, configure the interface.

sudo nano /etc/network/interfaces


For example:

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0

auto wlan0      <----start up interface at boot
iface wlan0 inet dhcp
   wpa-ssid "ssid"
        wpa-psk "password"
     wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf


(Including the "  " )



With the wpa-roam command, you can configure multiple SSIDs in one single place through the wpa_supplicant.conf file. If your Pi is not going to be roaming between different SSIDs, or will roam and stay withing the same SSID, then there is no need to configure this file, and all configuration can be done in your /etc/network/interfaces file.



Because I prefer not to use DHCP on my pi's (for easier SSH access). Here is the config for a static IP address:


iface wlan0 inet static
address 10.88.33.241
netmask 255.255.255.0
gateway 10.88.33.1
broadcast 10.88.33.255
wpa-ssid "El_Pendejo"
wpa-key-mgmt WPA-PSK
wpa-group TKIP
wpa-psk "Pietjepuk!"

 To manually bounce the interface:

 sudo ifdown wlan0 && sudo ifup wlan0

WPA2
Now, if you can, configure WPA2, as it is more secure. First thing do do, is check if your access point is actually set up to support WPA2 (which most do nowadays)

pi@raspberrypi ~ $ sudo iwlist wlan0 scan
wlan0     Scan completed :
          Cell 01 - Address: 90:F6:52:F6:11:2D
                    Channel:6
                    Frequency:2.437 GHz (Channel 6)
                    Quality=49/70  Signal level=-61 dBm
                    Encryption key:on
                    ESSID:"El_Pendejo"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s;6
                              9 Mb/s; 12 Mb/s; 18 Mb/s
                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master
                    Extra:tsf=00000028b9d730c1
                    Extra: Last beacon: 0ms ago
                    IE: Unknown: 000D50756B6B69655F6E65745F3234
                    IE: Unknown: 010882848B960C121824
                    IE: Unknown: 030106
                    IE: Unknown: 2A0100
                     IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (1) : TKIP
                        Authentication Suites (1) : PSK

As you can see from the scan output above my AP supports wpa2 on SSID "El_pendejo".


File/etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
#ap_scan=0
#update_config=1

network={
        ssid="YourSSID"
        psk="your-secret-key"
        scan_ssid=1
        proto=WPA2
        key_mgmt=WPA-PSK
        group=CCMP TKIP
        pairwise=CCMP TKIP
        priority=5
}


DIAGNOSTICS


To verify the wireless interface's signal strenth, SSID and associated AP issue:


iwconfig



http://wiki.gentoo.org/wiki/Wpa_supplicant

No comments:

Post a Comment