Raspbian Jessie: Set a static IP-address

For many of my projects on the Raspberry Pi a static, or fixed, IP-address has been needed. Here is a quick tutorial on how to set it up. This is aimed for SSH users who have no GUI on there Pi. Before you configured this by editing the network interfaces config file but not any more. Raspbian Jessie comes with dhcpcd5 by default and you can uninstall it it’s just easier to append to it’s configuration. Start by opening it’s configuration.

[bash]sudo nano /etc/dhcpcd.conf[/bash]

dhcpcd.conf

At the end of this line you can add a static IP-address configuration. Here is an example:

[bash]
#static ip
interface eth0
static ip_address=192.168.0.3/24
static routers=192.168.0.1
static domain_name_servers=8.8.8.8 8.8.4.4
[/bash]

First we specify the interface eth0 then all options follows with the prefix static. Ip address is specified with subnet, /24 is the equivalent of a subnet mask of 255.255.255.0. We also specify the networks default gateway for all traffic that will leave the network. In most cases this is your router for home built projects. We also need some DNS servers so we can use FQDN instead of just ip addresses when we communicate. In this example I have used the two Google DNS servers.

3 Comments on “Raspbian Jessie: Set a static IP-address”

  1. Hey just want to make sure…if my router’s IP address is 181.123.43.23 (for example) instead of 192.168.0.1, then at static ip_address line should I write something like 181.123.43.X/24 (24 for example) instead of 192.168.0.3/24?

    Like

  2. Pingback: Raspberry Pi ProtonVPN Gateway – …

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: