Setting up Raspberry Pi Wi-Fi

In this guide, I will show you how to set up the Raspberry Pi Wi-Fi via the command line and also how to do it via the GUI within Raspbian.

Raspberry Pi WiFi

I go into several topics in this guide that will help anyone grasp an understanding of how the Wi-Fi is set up on the Raspberry Pi.

I also touch on setting up the Wi-Fi country and predictable network interface names. These two topics are important if you need to tweak your Wi-Fi for your needs.

This tutorial is pretty straightforward, but for anyone who is entirely new to the Pi, these are vital steps that you will need to undertake to be able to setup your Raspberry Pi correctly.


I used the following equipment for this guide on the Raspberry Pi setup Wi-Fi.



In this guide, I use the default operating system for the Pi. This operating system (OS) is known as Raspbian, and if you haven’t got it installed, then you can follow my guide on how to install Raspberry Pi NOOBS (Raspbian).


If you want to see how to do this visually then check out the video I have prepared below.

As always if you like what you see, then please subscribe or follow us on social media so you can stay up to date with all the latest and greatest Raspberry Pi projects, guides and much more.

Adblock removing the video? Subscribe to premium for no-ads.

Setting up Raspberry Pi Wi-Fi Command Line

If you don’t have the option of setting up the WiFi connection up through the graphical user interface (GUI), then the command line interface (CLI) is the next best thing. It’s a little harder but still relatively easy to set up.

1. While in the terminal on the Raspberry Pi enter the following command.

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

2. At the bottom of this file, add the following lines.

ssid="The SSID of your network (eg. Network name)"
psk="Your Wifi Password"

3. Exit nano by typing CTRL + X and then Y to save.

4. The Raspberry Pi should in most cases notice the changes to the wpa_supplicant file and automatically make a connection to the Raspberry Pi.

If it doesn’t, you can force it to check by doing the following commands.

4a. This command takes the network interface down, meaning we can restart it to reload the wpa_supplicant file.

sudo ifdown wlan0

4b. This command brings the network interface up, upon it loading up, it will load the wpa_supplicant file back in.

sudo ifup wlan0

5. You can check if it has successfully connected by using ifconfig wlan0. The inet addr field should have an IP address in it.

If you’re on Raspbian Stretch the ifup command will likely not work, you will get an error that says something like the following “ifdown: unknown interface wlan0“. As a workaround to this issue, you can use either of the following commands sudo ifconfig wlan0 up or sudo ifconfig wlan0 down

Also, on Stretch, wlan0 may no longer be correct, use ifconfig to see the new name. For more information check out the predictive network names section further down this page.

If you’re having trouble connecting, then be sure to make sure that the Pi supports the Wi-Fi dongle. It is also possible you have the SSID wrong, to scan and check, use sudo iwlist wlan0 scan and check the essid field. This field should be the same as what you entered in the ssid field.

Setting up Raspberry Pi Static IP via Command Line

1. Setting up a static IP address for your Wi-Fi connection is a simple task that involves just modifying a single file.

While your WLAN connection should be identified as wlan0 you can verify this by utilizing the following command on your Raspberry Pi. Any Wi-Fi interfaces will be prefixed with wl.


2. Once you have verified your Wi-Fi connections interface name we can go ahead and modify the dhcpd config file. Begin modifying this file by running the command shown below.

DHCPD is the daemon that provides the Dynamic Host Configuration Protocol service to the network. Basically, it helps things like negotiating the IP address that the device should be using.

sudo nano /etc/dhcpcd.conf

3. Within this file, you need to add the following lines to the end of the file making changes where applicable. We will describe what each of these lines do below.

interface wlan0
static ip_address=
static routers=
static domain_name_servers=

interface wlan0 – This line defines the interface that we are wanting to modify the configuration for. If your wireless connection is not running on wlan0 make sure you change the interface name here.

static ip_address= – This is the IP address and size (/24) that you want DHPCD to acquire from the network. Make sure this is an unused address otherwise there will be conflict issues.

static routers= – This line defines the IP address of your router (or gateway). Make sure this matches the IP address of your router so DHPCD knows where to connect.

static domain_name_servers= – This line defines the DNS addresses that the DHCP Daemon will utilize for this interface. Typically this can just be set to the routers IP address.

4. You can now save the file by pressing CTRL + X then Y and finally pressing ENTER.

5. Now to make sure these changes are properly loaded in you should reboot your Raspberry Pi by running the following command in the terminal.

sudo reboot

6. You Raspberry Pi once rebooted should now stick to using the static IP address that you defined. You can verify your Raspberry Pi’s local IP address by running the hostname command.

hostname -I

It is also recommended that you also set a static IP address in your router itself for the device. This will ensure that there is no chance that another device will be handed the local IP address.

Setting up Raspberry Pi Wi-Fi via GUI

Using the GUI (Graphical User Interface) is the easiest way to set up Wi-Fi for the Raspberry Pi as everything can be done quickly within the interface.

1. You will need to have your Raspberry Pi connected to a monitor with a mouse and keyboard.

2. On the Raspbian desktop locate the Wi-Fi icon in the upper right-hand corner of the desktop.

Raspbian WiFi Icon Location

3. It will now scan for Wi-Fi networks and display any that it can find. Click on the network that you wish to connect to.

Raspbian WiFi Networks

4. If your network is password protected, then you will be prompted to enter a password. Enter the relevant password to connect to the Wi-Fi network.

Raspbian WiFi Password Field

5. The Pi should now connect to the Wi-Fi network, and the icon should have now changed to a blue Wi-Fi logo.

Raspbian WiFi Signal

Updating Wi-Fi Country

It is also a good idea to set the country for your Wi-Fi signal. Selecting the country in the GUI is pretty easy to do.

1. Go to the menu icon, then preferences then select Raspberry Pi configuration.

Raspbian Configuration Menu

2. In this menu, go to the localization tab and select “Set WiFi Country

Raspbian Set WiFi Country

3. Select your country and click save.

Raspbian Select WiFi Country

4. Your Wi-Fi country should now be updated.

Predictable Network Names

Predictable network names caused quite a bit of confusion when it was first introduced to Raspbian in the Stretch update. Since then, it’s been rolled back and can be activated manually.

You will find that predictable network names are useful when a device has multiple network connections. Instead of naming the interfaces wlan0 or eth0, it instead names them en (ethernet) or wl (wlan) followed by an x. It is lastly followed by a mac address (without any colons). For example, a wlan connection with a predictable network name would be called wlx6c198f049e5c

The naming was rolled back because most Raspberry Pi setups will only use a single ethernet and Wi-Fi connection. Also, a lot of tutorials rely on the naming of wlan0 or eth0. A lot of these tutorials weren’t updated to reflect the new naming which led to a lot of headaches.

The predictable naming comes in handy if you have three or more network interfaces. For example, on reboot, wlan0 might become wlan1 and vice versa. This switch of interface names may cause a lot of issues for people who rely on the interface names in their programs.

Predictable network names provide a naming convention that makes sense and is easy for a developer to predict.

If you wish to turn predictable network names on for use with the Raspberry Pi Wi-Fi or ethernet, then do the following steps.

1. In the terminal, enter the following command.

sudo raspi-config

2. Go to network options, then select network interface names. In here, select yes to turn on predictable network interface names.

3. Now exit raspi-config. You can test to see if predictable network names are working by entering the following command after you have plugged in a new network device. Devices that are currently connected might still have the old name, and a restart will fix this issue.

sudo ifconfig
Raspbian Network Predictable Names

It is important to note that the onboard Wi-Fi for the Raspberry Pi 3, and zero will continue to use wlan0. Despite whether predictable naming is turned on or off.

Now that you have your Wi-Fi setup you might be interested in doing a bit more with it. For example, setting up a Raspberry Pi Wi-Fi access point is a great way to help extend Wi-Fi coverage throughout your house. You will need to have ethernet connected to the Pi as a Wi-Fi to Wi-Fi setup isn’t great for speed.

If you’re having trouble getting the Wi-Fi to connect, then be sure to check that the Pi supports the dongle. This issue is one of the most common problems when setting up the Raspberry Pi Wi-Fi.

I hope that this guide has been able to show you all the steps to set up Wi-Fi on the Raspberry Pi and you haven’t run into any issues. If you require further assistance, I highly recommend that you leave a comment below.


  1. Avatar for XBVR
    XBVR on

    Use command to enable wifi via cli:

    sudo rfkill unblock 0

    Note: I think this should be added to the tutorial 😉

  2. Avatar for Bill
    Bill on

    Gus, I have a RPi 3 and would like to install an 802.11ac USB adapter. I have tried an Edimax EW-7822UAC and a Netgear A6200. I’ve plugged each into a powered hub to make sure that the power draw required isn’t the issue. Each shows up in the result of a dmesg command, but I can’t get either to show up as a wlanx device. I did a speed test with the built in WiFi and got 5.1 Mbps down, but a wired connection gives me 86 Mbps down. On my Intel based computers, I can get speeds close to a wired connection with those same adapters – even with a USB 2.0 connection.

  3. Avatar for Harry
    Harry on

    My pi wont work on any wifi receiver help

  4. Avatar for anja
    anja on

    I tried in the past to get both connections, LAN and WLAN. The descriptions in the past are always very difficult.

    But this works very quick and very easy.

    Great job / Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *