About me and my Pi

How To's

Using vnStati
Setting a static IP
RPi as a DNS slave
Setting up fail2ban
Install Nginx & PHP

Other stuff here

PHP System Info
Icecast Server
Stuff (folder)

External links

Setting a static IP on your Raspberry Pi / Linux

This page explains how to configure a static IP on your Raspberry Pi / Linux machine, presuming you already know the IP address to use, the gateway IP and the netmask. Things are different on Raspbian Jessie, which is where I will start. For Wheezy, see further down.

So, they changed the way you configure your network interfaces in Raspbian Jessie and not for the better! In /etc/network/interfaces there is a comment telling you:

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

So, lets go there:

sudo nano /etc/dhcpcd.conf

In previous versions (see below), we set up the netmask, network and broadcast IP's, but in Jessie, we just use the netmask bits (eg /24) after our actual IP to set these automatically. Also, we no longer set our name servers in /etc/resolv.conf but in /etc/dhcpcd.conf

Add these lines at the bottom of /etc/dhcpcd.conf

#Static IP Setup
interface eth0
static ip_address=
static routers=
static domain_name_servers=

Adjust to suit. Most people would use /24 netmask bits, for 254 useable IP's.

Now for the usual 'old' settings before Jessie!

Open the interfaces file in nano:

sudo nano /etc/network/interfaces

The default looks like:

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

Now, we dont need wlan0 or any default settings, or DHCP on eth0, so we can change the file to a manually configured eth0, like this (these are my settings, so change yours to suit!):

auto lo
iface lo inet loopback

iface eth0 inet static

To work out the network and broadcast IP's, we use the netmask. I use a netmask of (or /26 netmask bits), as it gives me 62 useable IP addresses and thats more than enough for my home network, therefore my 'network' is, my 'broadcast' is and my gateway (router) is The 62 IP's inbetween are the useable IP's.

Most home networks will be using the netmask (or /24 netmask bits), giving 254 useable IP's. In this case, the 'network' will be x.x.x.0 and the 'broadcast' would be x.x.x.255. There are many online calculators to help you find these values.

You should know how your router/gateway is set up with regards to IP addresses (or set it up yourself), so you know which are available for static use and what range is in the DHCP pool. This is how I have mine:

Most of the equipment on my home network is setup with a static IP, however I have set my DHCP (v4) pool to have to which is plenty. This leaves me with to to assign myself, although I have used for my gateway.

Good luck setting up your home network and learning along the way!


Back to home...