Setting up Raspberry Pi WiFi with Static IP on Raspbian Stretch Lite

So here we are. Ready to setup the WiFi and static IP settings on the Raspberry Pi running Raspbian Stretch Lite. And because it’s Lite, all we can use is the command line. But what do we exactly do to get the job done? Here are some steps you might want to consider when wrapping your head around the WiFi and static IP setup process:

  1. Check the available interfaces.
  2. Search for the WiFi network you want to connect to.
  3. Set up the wpa_supplicant.conf file.
  4. Set up the dhcpcd.conf file.

Steps 1 – 3 are for the Raspberry Pi Raspbian Stretch Lite WiFi setup. Step 4 is necessary to get the static IP going.

Step1: Check the available interfaces

On your Raspberry Pi, type ifconfig to get all the available network interfaces. If you are using a Raspberry Pi 3, you should see the wlan0 interface somewhere in the output.

Step2: Search for the WiFi network you want to connect to

Type sudo iwlist wlan0 scan to get your Raspberry Pi to list up all the WiFi networks it was able to find. The Result of this command will look something like this.

We are interested in the  ESSID tag. Look for the network you want to connect to. If it shows up in this list, your chances of getting your Raspberry Pi connected to the WiFi are high.

Step3: Set up the wpa_supplicant.conf file

Now that we’ve found our WiFi network, we need to tell the Raspberry Pi to connect to it. To do that open /etc/wpa_supplicant/wpa_supplicant.conf with your favorite text editor tool. If you are using Raspbian Stretch Lite, it should look as follows.

Now add the snipped below to  wpa_supplicant.conf.

After adding the snippet, the  wpa_supplicant.conf file should now look like this.

Needless to say, you’ll have to replace  your-networks-SSID and  your-networks-password by your networks actual parameters.

Read more about the settings in this step in the Raspberry Pi documentation.

Step4: Set up the dhcpcd.conf file

Open  /etc/dhcpcd.conf with your favorite text editor. scroll down until you see the following commented out lines of code.

Now copy the following snippet and put it right under the code shown above.

You will need to set up the  static ip_address and static routers tag to fit your network setup. Don’t forget to save the file. And, if you plan to use SSH, also don’t forget to enable SSH via sudo raspi-config! Now you should be able to connect to your Raspberry Pi via SSH by using the static IP you’ve just set up.
In the case you never used SSH before, here’s a hint on how to get started. Download putty (if you’re on Windows) and open it.
You will see a dialog box like the one above. Writing your Raspberry Pi’s static IP in the Host Name field will be all that’s needed to start a SSH session.
One last thing. Now that you have enabled SSH it is a very good idea to change your Raspberry Pi’s password. If you have not already done this, do this now. The password can be changed by typing passwd.

Now that you’ve set up the wifi on your Raspberry Pi, you might wonder what’s next. You might get some ideas by skimming through this blog post: Raspberry Pi Robot Arm with simple Computer Vision

Published by


Author and Webmaster of this blog. Likes electronic things and programming. And Japanese. It's such a nice language!

One thought on “Setting up Raspberry Pi WiFi with Static IP on Raspbian Stretch Lite”

  1. hi MR
    you have best many projects and i am happy whene to know you ,i think you have to on to devlopement with c# and we laern from you et thanks for this many hardwork

Leave a Reply

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