Hackviking He killed Chuck Norris, he ruled dancing so he took up a new hobby…

12Jun/162

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.

sudo nano /etc/dhcpcd.conf

dhcpcd.conf

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

#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

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.

Posted by Kristofer Källsbo

Comments (2) Trackbacks (0)
  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?

  2. Correct! It needs to be in the same subnet. But that IP address is not a private address it’s a public one so you should double check the information before proceeding!


Leave a Reply

No trackbacks yet.