Configuring a Static IP address on your Raspberry Pi

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

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.