D-link DWA-127 and Raspberry Pi

D-Link DWA-127
D-Link DWA-127 USB WiFi

This Christmas I got a D-Link DWA-127 Wireless N-150 High Gain USB Adapter from a friend as a gift. He thought I should use it when I am in London, as WiFi are quite poor there, hence high gain. I wondered if it would work with my Raspberry Pi Model B+ which I have at home, and it worked without any hustle.

My Raspberry Pi is running Raspbian GNU/Linux 7 and currently using the Linux raspberrypi 3.12.28+ #709 PREEMPT Mon Sep 8 15:28:00 BST 2014 armv6l GNU/Linux kernel. I’ve not modified the kernel in any way.

I started with connecting the DWA-127 to the Raspberry Pi using one of the USB-ports. Then I logged into (ssh) it over Ethernet (cable) and issued the ifconfig -a command:

$ ifconfig -a
eth0      Link encap:Ethernet  HWaddr b8:27:eb:5c:6f:cc
          inet addr:192.168.1.130  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:445954 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7320 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:46652938 (44.4 MiB)  TX bytes:665073 (649.4 KiB)

wlan0     Link encap:Ethernet  HWaddr bc:f6:85:67:ea:bd
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

My Raspberry had recognized the USB Wifi instantly. Great, so it works. As I am using WPA2 for my WiFi at home I need to configure the interface:

$ sudo vi /etc/network/interfaces

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

To setup the SSID and WPA-PSK (pre shared key) I used the wpa_passphrase command:

$ sudo wpa_passphrase MY_WIFI_SSID MY_WIFI_PASSWORD
network={
ssid="MY_WIFI_SSID"
#psk="MY_WIFI_PASSWORD"
psk=e144..LOTS_OF_RANDOM_CHARS
}

I copied the output above and pasted it into the end of the /etc/wpa_supplicant/wpa_supplicant.conf file:

$ sudo vi /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="MY_WIFI_SSID"
#psk="MY_WIFI_PASSWORD"
psk=e144..LOTS_OF_RANDOM_CHARS
}

Then I restarted the wlan0 interface:

$ sudo ifdown wlan0
$ sudo ifup wlan0

And checked that the inteface had got an DHCP-assigned IP address from my network router:

$ ifconfig -a
eth0      Link encap:Ethernet  HWaddr b8:27:eb:5c:6f:cc
          inet addr:192.168.1.130  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:446727 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7681 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:46712579 (44.5 MiB)  TX bytes:707597 (691.0 KiB)


wlan0     Link encap:Ethernet  HWaddr bc:f6:85:67:ea:bd
          inet addr:192.168.1.243  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:642 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:254200 (248.2 KiB)  TX bytes:1436 (1.4 KiB)

That is all. I tested to reboot the Raspberry to make sure it brings up the interface during boot and when that verification was done I removed the Ethernet cable. Now it’s all on WiFi.

If you don’t have wpa_supplicant installed, use the following commands:

$ sudo apt-get update
$ sudo apt-get install wpasupplicant