Raspberry Pi Static IP Address Simple Tutorial

This tutorial will show you how to easily give your Raspberry Pi a static IP address on your local network. If you do not do this, your IP address may change from time to time on your local network. To give your Raspberry Pi a static IP address just follow these basic Steps.

Start: Raspberry Pi Static IP Address Simple Tutorial

I started out by using SSH to connect to my Raspberry pi.

Step 1: Check our your current network setup

This will show you your current wireless setup and wpa_supplicant information. This is my setup:

Raspberry Pi Static IP Address Tutorial

Step 2: Get the IP Address of your Raspberry Pi

Run the ifconfig command.

This gives us information regarding our router and wireless connections. We need to get the information located at the wlan0 area towards the bottom. I have indicated the area below.

Raspberry Pi Static IP WLAN0 Tutorial

 

Step 3: Copy and paste information from ifconfig command

Copy and paste the following information into a text file for later use when we configure the static IP address for your Raspberry Pi.

CURRENT IP
net addr:192.168.1.11

BROADCAST IP
Bcast:192.168.1.255

SUBNET MASK
Mask:255.255.255.0

 

Step 4: Copy and Paste information from netstat -nr command

This will give us even more information about where our Raspberry Connected and how it is being broadcasted in our local network. Run the following command:

You should end up with something like below. I have highlighted the important information we need to add to that text file for later.

Raspberry Pi Static IP Netstat Command

So now we should have the inet, Bcast, Mask, Destination, and Gateway. So my text file looks something like this:

Raspberry Pi Static IP Netstat Command 2

 

Step 5: Format so that we can paste this information into the /etc/network/interfaces file

Now we just have to change what we have about to something that looks similar to:

 

Screen Shot 2015-10-27 at 7.44.59 PM

 

Step 6: Change /etc/network/interfaces file

From our old file we will change the lines marked in red

OLD FILE (lines to change in red)

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

 

Run the command:

to make the following changes

NEW FILE (changes in red)

auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.1.11
broadcast 192.168.1.255
netmask 255.255.255.0
network 192.168.1.0
gateway 192.168.1.1

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Step 7: Remove existing leases

Run the following comand:

When you are finished rebooting SSH back into your Raspberry Pi and check your ip address by running

You now have a Raspberry Pi with a Static IP Address!

Be sure to comment any questions or concerns below. Thanks for reading!

Hardware Used

CanaKit Raspberry Pi 2 Complete Starter Kit (9-Items) (Personal Computers)


List Price: $129.99 USD
New From: $60.00 USD In Stock
Used from: $48.99 USD In Stock

Leave a Reply

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