Configuring a Static IP address on your Raspberry Pi

Revision as of 15:17, 23 December 2012 by Andrum99 (talk | contribs)
Jump to: navigation, search


RaspPi.png Back to the Hub

Getting Started:

Buying Guide - for advice on buying the Raspberry Pi.

SD Card Setup - for information on how to prepare the SD Card used to boot your Raspberry Pi.

Basic Setup - for help with buying / selecting other hardware and setting it up.

Beginners Guide - you are up and running, now what can you do?

Latest RPi 4 Topics - Recent topics on Raspberry Pi 4 and the Pi OS

Advanced Setup - for more extensive information on setting up.

Trouble Shooting - some things to check if things don't work as expected.

By default the Raspberry Pi uses DHCP to configure its network interfaces, including, on the model B, the built-in ethernet port. If you want to change this so the ethernet port has a static IP address, here's how.

DHCP for eth0 is enabled in the file /etc/network/interfaces. Here is what it looks like by default on a Raspberry Pi under the official version of Raspbian:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

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

(Note: there is no actual wlan0 interface unless you attach a wireless USB network adapter. The entries that refer to wlan0 are there for when you do ;-) ).

Instead of the line:

iface eth0 inet dhcp

you need lines like this:

iface eth0 inet static

The above example assigns the address to eth0 with a subnet mask of, and sets the default gateway to

Edit the file /etc/network/interfaces with the nano utility like this:

sudo nano /etc/network/interfaces

The second thing you need to do is check that you have a valid DNS server listed in /etc/resolv.conf. Edit this file using nano and add your DNS server if it is not already there. If you are using a broadband router, add the address of your router as the DNS server.