Using a static IP address with Raspbian Jessie

Published on Author roving_adventurerLeave a comment

Here is a brief rundown on how to set a static IP address on Raspbian Jessie, including getting DNS resolution to work which can be problematic with the default packages installed with Jessie.

In Jessie, the static IP address is set in the dhcpcd.conf file, hence edit this using

% sudo vi /etc/dhcpcd.conf

Add the static IP configuration at the end of the file. You need to add a separate configuration for each network interface, so you can have a different configuration for wired or wireless if you like.

To add a static IP configuration for the first wireless adapter, add the following lines:

interface wlan0

static ip_address=<ip address CIDR, e.g. 192.168.0.150/24>
static routers=<router ip address, e.g. 192.168.0.1>
static domain_name_servers=<space delimited list of domain names servers>

Similar, to add a static IP configuration for the first wired adapter, add the following lines:

interface eth0

static ip_address=<ip address CIDR, e.g. 192.168.0.151/24>
static routers=<router ip address, e.g. 192.168.0.1>
static domain_name_servers=<space delimited list of domain names servers>

These changes will take effect for the configured adapters on the next reboot.

However you may find that DNS resolution does not work if the resolvconf package is not installed. To install:

% sudo apt-get install -y resolvconf

In order to test DNS with the nslookup and dig tools, these can be installed with:

% sudo apt-get install -y dnsutils

Leave a Reply

Your email address will not be published. Required fields are marked *