Raspberry Pi + Cantenna: Ultimate 2.4GHz Wardriving and Long-range WiFi Access

Want to turn your Raspberry Pi into a portable antenna / wireless router that can be used to pick up WiFi signals from great distances?  I did.  I will walkthrough how to make the 2.4GHz cantenna using some cheap components and then setup the Pi as a router so you could search for WiFi access points, connect to them, and potentially relay the signal. Great for wardriving or just connecting to your home Wi-Fi from out in the backyard.

Requirements For This Walkthrough


  1. Mac or PC
  2. A cantenna with an N-male to RP-SMA-male cable
  3. A Wi-Fi USB Adapter with removable antenna that does not require a powered USB hub (ideally) or just use the exact model adapter that I used for this walkthrough
  4. Raspberry Pi, model-B running “Wheezy”


  1. None

Knowledge, Skills, and Abilities

  • Basic understanding of wireless networking concepts
  • Ability to connect peripherals to a computer
  • Knowledge of basic computer terminology
  • Ability and confidence to enter commands in the Terminal, adjusting them to suit your environment, if necessary


Connect All Hardware

Connect USB Wi-Fi Adapter

Once the USB adapter is plugged in, run the command lsusb  to see if there is an entry for the Wi-Fi adapter, then it is ready to go.  Some adapters work out of the box, but others require some more intervention.  I like to keep things easy, so I selected an adapter that I knew would work (plus, it was cheap).

  1. Remove the antenna from the USB adapter if it is connected
  2. Plug the adapter into the RPi
  3. Type the lsusb  on the RPi to see if the adapter is recognized

Depending on what else is plugged into the pi, the command’s output should be similar to the following (look for an entry relating to a wireless adapter).

Bus 001 Device 002: ID 3980:4389 Standard Microsystems Corp. 
Bus 001 Device 001: ID bfde:3293 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID ffe2:380d Standard Microsystems Corp. 
Bus 001 Device 004: ID 4b5a:nd02 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter

Connect Cantenna to the RPi

Connect the cantenna to the the USB adapter using the pigtail cable.

Scan for Wireless Network

From the Command Line

Scan for Wi-Fi Access Points

Point the cantenna at an area likely to have access-points.  Scan for wireless networks from the command line (with lots of additional information)

sudo iwlist wlan0 scan

Depending on how many networks there are, there might be a lot of data to sift through.  Most of it is the same information you would find in a GUI app, but it is just a little more messy.  You can pipe the output through a few other commands if you just want the SSIDs.  This is great if you quickly want to see what access points your cantenna is picking up.

sudo iwlist wlan0 scan | grep ESSID | cut -d"\"" -f2 | sort -n

The above command will scan for wireless networks, parse out the SSIDs, cut out the unnecessary information, and then sort it by name.  It is just to make the output more human-friendly.

Alternatively, the following command will show just the most-common information: the SSID, the protocol, the security, and the signal strength.

sudo iwlist wlan0 scan | awk '/ESSID|Quality|IE/' | cut -d"\"" -f2
     Protocol:IEEE 802.11bg
     IE: WPA Version 1
     Quality=80/100 Signal level=36/100 
     Protocol:IEEE 802.11bgn
     IE: IEEE 802.11i/WPA2 Version 1
     Quality=100/100 Signal level=47/100

Save Commands as Aliases

If you plan to do this a lot, I would suggest making these commands into aliases by adding them to the ~/.bash_aliases  file (creating it if it does not exist).  The other commands are more difficult to save as aliases due to the need to escape the special characters, but the two below should help save time.

alias ssids='sudo iwlist wlan0 scan | grep ESSID | sort -n' 
alias ws='sudo iwlist wlan0 scan'

It is necessary to logout and then login before the aliases become active.

From the GUI

Being a command-line junkie, I tend to do things there, but I also appreciate how much easier the GUI can be.  This might be a better way to do it if your Pi is hooked up to a monitor.  If your pi is not booted to the GUI by default, you can start it with the command startx .  It can be permanently enabled via sudo raspi-config

Once booted to the GUI, there should be an app called Wi-Fi Config.  From this app, you can scan the available networks and have all of the same data that was available in the command line presented in an organized way.  With the Pi having limited resources, I tend to choose using the command-line instead, but either option is viable.  Use whatever you like!

Connect to an Available SSID

From the Command Line

Now that you can see what networks are available, you need to edit a config file to connect to it.  Most likely, you will be connecting to an SSID where you know the password (unless you are wardriving).  So just open /etc/network/interfaces  in a text editor

sudo vi /etc/network/interfaces

The following four lines should be in the file (some may be there already)

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

Next, edit /etc/wpa_supplicant/wpa_supplicant.conf  with the specifics of the network you are attempting to connect to

sudo vi /etc/wpa_supplicant/wpa_supplicant.conf

The file should look similar to the following (but with your network settings in place)

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


# Protocol type can be: RSN (for WP2) and WPA (for WPA1)

# Key management type can be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise)

# Pairwise can be CCMP or TKIP (for WPA2 or WPA1)

#Authorization option should be OPEN for both WPA1/WPA2 (in less commonly used are SHARED and LEAP)

Reboot to apply all of the settings

sudo reboot

From the GUI

Use the Wi-Fi Config app (usually, it is on the Desktop) to choose the network to connect to.

Other Ideas for the Pi + Cantenna