Setting a Static IP Address on Your Pi

To perform the following steps, you'll need to have a USB keyboard plugged into your Pi and the Pi plugged into a TV or monitor.

1. Wait for the Pi to fully boot up and take note of the IP address after "My IP address is".

2. Log in using pi as the username and raspberry as the password.

3. Type the this command: sudo pico /etc/network/interfaces and hit Enter.

4. Enter the following info in the document that appears. The info in red is what you should type in; the rest should already be there.

If using Wi-Fi:

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

address 192.168.1.97 <<< NOTE: This IP address should start with the first three octets of the IP that you noted in the first step (e.g. 192.168.0 or 192.168.1), followed by .97.

netmask 255.255.255.0
network 192.168.1.0 <<< NOTE: Same as note above except the last digit should be 0.
broadcast 192.168.1.255
gateway 192.168.1.1  <<< NOTE: Same as note above except the last digit should be 1.
dns-nameserver 127.0.0.1

manual eth0
allow-hotplug eth0
iface eth0 inet dhcp
dns-nameserver 127.0.0.1

 

If using Ethernet:

auto eth0

allow-hotplug eth0

iface eth0 inet dhcp
dns-nameserver 127.0.0.1 
iface default inet static 
address 192.168.1.97 <<< NOTE: This IP address should start with the first three octets of the IP that you noted in the first step (e.g. 192.168.0 or 192.168.1), followed by .97. 
netmask 255.255.255.0 
network 192.168.1.0 <<< NOTE: Same as note above except the last digit should be 0. 
broadcast 192.168.1.255 
gateway 192.168.1.1 <<< NOTE: Same as note above except the last digit should be 1.

5. Press Ctrl + O to save and then press Ctrl + X to close the document.

6. Reboot the Pi with the command: sudo reboot.

Your Pi should now have a static IP address. You can double-check this when the Pi boots up again by making sure the IP is 192.168.X.97.