How to set up WiFi on a Raspberry Pi

Although the Raspberry Pi Model B comes with built-in 100Mbps wired Ethernet, it can also use WiFi via a USB dongle. The Model A doesn’t come with Ethernet at all, so using a WiFi adapter is a good way to get networking on that model. In both cases, simply plugging in a supported USB dongle and doing a simple bit of configuration will give your Pi access to wireless.

You can get yourself a USB adapter for less than $10 but it is important to buy one which is supported by the Raspberry Pi and Linux. For this tutorial, I will be using a dongle based on the Realtek RTL8188CUS chipset. The Realtek chipset is supported by Raspbian out-of-the-box and no additional configuration is needed for it to be recognized during boot.

The RPi USB Wi-Fi Adapters page has a comprehensive list of supported wireless adapters. If you are considering buying a dongle, you should check that page for compatibility.

Plug in the USB adapter and boot your Raspberry Pi. There are several ways to check if the adapter has been recognized. The easiest is to type:


You should see a listing for eth0 – the built-in wired Ethernet port; for lo – the loop back device; and wlan0 – the wireless adapter.

Alternatively you can list the current USB devices attached to the Pi using:


The list should contain your wireless dongle. On my setup, the list shows a “Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter”.

Desktop set up

If you are using the desktop on Raspbian than connecting to a wireless network is quite easy. Double click the “WiFi Config” icon on the desktop to start the wireless configuration program. The “Adapter:” field will show your USB dongle (i.e. wlan0) and the “Network:” field will be empty (unless you have previously configured a wireless network). Click the “Scan” button. Now click “Scan” on the “Scan results” window. A list of the available wireless networks will be shown along with their signal strengths etc. To connect to one of the listed networks, double click on the SSID.


On the connection window, verify the “Authentication” and “Encryption” fields and enter the password in the “PSK” field. Now Click “Add”. Close the “Scan results” window. The configuration program will automatically connect to the newly configured network.


You can add multiple networks by repeating the same steps. You can select the desired network using the “Network:” drop down list. You can also connect and disconnect using the relevant buttons. You can use the “Managed Networks” tab to edit and remove networks.

Command line set up

If you aren’t using the desktop then the WiFi can be configured using the command line. Raspbian should come with all the correct packages pre-installed but if any of the commands or files mentioned below aren’t available, then run this command to install them:

The general network settings are configured in “/etc/network/interfaces” while the Wi-Fi details are set in the “/etc/wpa_supplicant/wpa_supplicant.conf” file. First edit the “interfaces” file:

Ensure that the section about wlan0 (typically found at the end of the file) reads as follows:

If there are difference then change them to accordingly. Don’t alter any of the lines about the lo adapter or the eth0 adapter. Press “CTRL + X” to exit nano (press Y and then press ENTER when prompted).

To get a list of the currently available wireless networks, use the iwlist command:

If there is too much information, use grep to find the fields you need. For example to see just the ESSIDs, use:


Pick a network and add the network authentication information in the “wpa_supplicant.conf” file:

The first two lines should already read:

Now add the following:

If your router is configured using WEP for encryption then the network information will look like this:

For those of you familiar with advanced WiFi configurations, the network information can also include the following fields:

  • proto – Protocol type can be: RSN (for WP2) and WPA (for WPA1).
  • pairwise – CCMP or TKIP (for WPA2 or WPA1).
  • auth_alg – authentication algorithm, can be OPEN for both WPA1/WPA2 and less commonly SHARED or LEAP.

Press “CTRL + X” to exit nano and save the file, press Y and then press ENTER when prompted. Finally reboot your Pi:

You can check the status of the wireless connection using ifconfig (to see if wlan0 has acquired an IP address) and iwconfig to check which network the wireless adapter is using.


If you have any questions about wireless on the Raspberry Pi, please ask them in the comments and we will see if we can help.

Gary Sims

Gary has been a technical writer, author and blogger since 2003. He is an expert in open source systems (including Linux), system administration, system security and networking protocols. He also knows several programming languages, as he was previously a software engineer for 10 years. He has a Bachelor of Science in business information systems from a UK University.


  1. I would recommend you to use the command ip(8) instead of ifconfig(8) as the last one are deprecated. Same with arp(8) and route(8). They are also replaced by the ip command.

    ip addr show – ifconfig
    ip route show – route
    ip neigh show – arp(8)

    And lots of configuration can be done with /etc/internet/interfaces together with wpa-driver and wpa-roam stansa and use id_str=”key” in wpa_supplicant.conf file network config. Please look into manual page wpa_action(8) for more information.

    But this is a greate start.

    1. i can scan my wifi and i see my wlan but ras pi could not get a ip address from my wifi router (dhcp is configured on) when i start the ras pi gui and start wifi network it is empty.

      any idea?

      cu, Klaus

  2. I take my Pi from place to place and would like to store the SSIDs and passwords of more than one network. Would you just repeat the network={…} code in the wpa_supplicant.conf file for each network?

    1. Melb, thanks for the tip, yes wicd-curses is a good tool for those who don’t want to get their hands dirty!

  3. Thanks for this tutorial. I have been struggling to setup my wireless until i found this. You rock man

  4. Great tutorial. Can I just omit the psk or key lines for ssid’s that are open (e. g. Not password protected)

    Do I also need to say key_mgmt = none?

    1. I was looking for an answer to this as well, and it’s looking like if the network has no authentication/plaintext, you omit the psk key and include key_mgmt=NONE, eg.,


  5. Hello

    I’m trying to use the desktop setup, but for some reason it isn’t working for me. I have the Edimax 150Mbps Wirelss 802.11b/g/n nano USB adapter. Once I click scan my router does show up, but when I put in the correct password and try to use the internet, it seems to have not gone through.

    Also, when I tried the command line steps that didn’t work either. Now, when I go scan to get the list of available wifi routers, nothing shows up.

      1. ensure you use the sudo command. For me, the files came up blank when I had left that out.

  6. i am using a model A right here and and WiFi dongle is TL-WN727N from TP-LINK. cant seem to connect to internet at all. When i start up the pi, (/etc/network/interfaces) failed. Any help would be much appreciated. TIA

    1. Hi,

      I haven’t used that Dongle myself but looking here: there seems to be people who have had trouble getting it to work. That particular forum post is from 2012, so I don’t know if it is still relevant.

      Does ifconfig show the wlan0 device???


    2. @Shawn: Follow instructions on [(UPDATE) Drivers for TL-WN725N V2 – 3.6.11+ -> 3.12.24+]

    3. More than likely because it has a ralink chipset. Try finding a card that has realtek or atheros chips. Chances are they will work out of the box

  7. Been struggling to get my wi fi dongle up and running but without success (on Raspbian)

    Tried several suggestions from different forums
    the following is response to the command

    $ sudo iwlist wlan0 scan
    wlan0 Interface doesn’t support scanning.

    other commands and responses

    $ 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 0bda:8179 Realtek Semiconductor Corp.
    Bus 001 Device 005: ID 0e8f:00a5 GreenAsia Inc.

    $ iwconfig
    lo no wireless extensions.

    eth0 no wireless extensions.

    However ifconfig does give the following:

    pi@raspberrypi ~ $ ifconfig
    eth0 Link encap:Ethernet HWaddr b8:27:eb:d4:88:d2
    inet addr: Bcast: Mask:
    RX packets:1703 errors:0 dropped:0 overruns:0 frame:0
    TX packets:1880 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:1543727 (1.4 MiB) TX bytes:218299 (213.1 KiB)

    lo Link encap:Local Loopback
    inet addr: Mask:
    UP LOOPBACK RUNNING MTU:65536 Metric:1
    RX packets:2 errors:0 dropped:0 overruns:0 frame:0
    TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:276 (276.0 B) TX bytes:276 (276.0 B)

    Please Note: the same dongle works fine on RASPBMC in fetching add ons , you tube videos etc

    Thankx in advance for your time and help….

    1. Hi Jadhav,

      I have the sample problem. Were you able to solve this issue? If so, please advice.



  8. Like many others, I had trouble with both the WiFi Config and following this guide. In the end, used Wicd-curses

  9. I’m using a CanaKit B+ PI with the 150 MBPS USB Wireless Adapter (model CKXW1000). It connects then drops out after 5 seconds, and repeats this process endlessly. Please advise.

  10. It worked. Very nice explanation. The ability to check the work was the best part. I was able to see that the changes I made at first did not work. A bit of trouble shooting and I found the error. Very nice.

  11. I’m using a Netgear N300 wireless adapter. It doesn’t even show up inside of the ifconfig but it shows up in the lsusb.

    Any idea? I’ve tried both powered usb hub and directly connected. (works on Windows just fine).

  12. I just bought the Adafruit miniature wifi module. The main reason I bought it is to make my raspberry pi wire-free (except the power cable). I don’t want to use a separate keyboard, mouse and monitor for the pi, and I always use ssh and vpn to control the pi from my mac. Now this is my question. Is it possible to have the raspberry pi connect automatically to the wireless network upon boot? (I have already assigned a static IP to the pi using its mac address). In other words, I do not want to connect the pi to a monitor and run the wi-fi config every time. I want to just connect the pi to the power, and start controlling it using ssh (assuming the wifi module automatically connects the pi to my network). It this possible?? Help much appreciated. Thanks!

    1. i guess first you will have to configure pi in wifi mode as per the instructions in this guide. Then you can install vncserver so that you can work in a headless mode.

  13. Excellent article. Espcially the command to scan the wireless networks using iwlist helped me. I had configured incorrect group-cipher, pairwise cipher and auth-suites. This command helped me get the correct values to be set. Next step is to configure VNC server so that i can work in a headless mode.

  14. when i type-
    sudo iwlist wlan0 scan

    i get this error-
    wlan0 interface doesn’t support scanning

  15. One additional note regarding the WEP configuration in /etc/epa_supplicant/wpa_supplicant.conf
    Add the following line to force the use of wep_key0:


    1. Depends on the keyboard layout, but on mine (UK English) it’s to the left of the ‘Z’ key, as a Hold Shift extension to the ‘\’. yeah, left of ‘Z’ key is ‘\’, hold shift and press it to get ‘|’

  16. Can’t make any of this work. I’m a total beginner. Help please? Got Wi-Fi adapter to find my Wi-Fi network but doesn’t seem to connect to the net.
    Help please?

  17. The dialog box with the add button is off my screen and I cannot resize it so that I can see the add button. Any ideas?
    Thank you

  18. When I list event history from wpa_gui _it shows 4Way handshake failed, pre-shared key may be incorrect. Under STATUS I get: Could not get staus from WPA_SUPPLICANT
    Last message signal 15 received.

    I am using a RASPERRY PI B1 and 150 Mbps 802.11N/G/B RALINK TECH. RT5370 Wireless adapter.


Comments are closed.