Setting a Static IP Address on a RaspberryPI

Static IP Address on a RaspberryPI

 

Let us have a quick look at setting up a static IP address on a Raspberry PI, For this guide I will assume you have already configured the bare basics and that you already have a the command shell in front of you. Also going to assume that you already have some settings in mind or else you would probably not have found your way here. This guide quite obviously works for most linux distributions out there as well.

First thing you need to do is edit the interfaces file by running the following command;

Raspberry_PI_Static_IP_command

The line that currently shows DHCP (iface eth0 inet dhcp) configuration needs to be replaced as follows, remember to replace the settings with your own details as required.

Raspberry_PI_Static_IP_interface_file

You will also need to configure nameservers to ensure that DNS resolution continues to function, again I will assume that you have some settings already, if not you can point directly at your gateway which should work in most basic configs. Once again you need to edit a text based config file in order to make the changes;

Raspberry_PI_Static_IP_command_nameservers

The file should be edited as follows, note that you simply add more lines if you have multiple DNS servers available

Raspberry_PI_Static_IP_nameservers

After this you simply need to reboot the RaspberryPI and your settings will be applied, (you don’t actually have to reboot but it is easier for most). And there you have it, a simple guide to setting up a static IP address on a Raspberry PI or any other Linux machine for that matter.

To fastest way to test everything is to run a quick “ping www.google.com” after rebooting, if it responds you have configured your Raspberry PI static IP address correctly. If it does work you need to double check the above settings and ensure that your addresses are correct and if all else fails make sure that the network cable is plugged in and actually works.

Leave a Reply