Jeff Geerling has discovered in his work on the Raspberry Pi Dramble cluster that Raspbian Jessie does networking a bit differently. Whereas before (with Wheezy) it was just a case of adding some lines to /etc/network/interfaces, now you need to add some lines to /etc/dhcpcd.conf to make dhcpcd5 set the static IP address. He’s blogged about it here but just for posterity (in case his blog disappears, as others have), here are the essentials for setting a static IP for your wired connection:
So, in /etc/network/interfaces, you add:
auto lo iface lo inet loopback iface eth0 inet static address 10.0.1.60/24 netmask 255.255.255.0 gateway 10.0.1.1 dns-nameservers 8.8.8.8 8.8.4.4
And then to /etc/dhcpcd.conf you add:
interface eth0 static ip_address=10.0.1.60/24 static routers=10.0.1.1 static domain_name_servers=8.8.8.8 8.8.4.4
This should give you a static IP of 10.0.1.60.
He has some other tips on his blog, so head over there if you want to read more.
It’s just wrong! the DHCP client should have nothing to do with static IPs (except via DHCP server leases) and should honour an interface’s desire not to be controlled by DHCP.
I will certainly try this, so that I can pin down a static IP for my Pi – and my Zero.
A query before I start again on my quest for the elusive static IP: can I, and indeed should I, try to assign separate IP addresses for my Pi and my Zero?
Thanks
It’s a good idea to set static IPs for all the Pis on your network. Remember, though: it’s essentially the SD card you’re setting the address on, so if you were to swap the SD cards of a couple of Pis, you would be swapping the IP addresses as well.
Nothing needs to be added to /etc/network/interfaces when implementing a static IP on Raspbian Jessie. (this is somewhat counter-intuitive to other Linux distros, but it is what it is…)
As it says at the head of the file:
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and ‘man dhcpcd.conf’
The only file requiring an edit is /etc/dhcpcd.conf as shown in the article.