Setting a static IP on Raspberry Pi on Raspbian 20150505

By | 28 August 2015

For setting a static IP for the Raspberry Pi 2 on the latest Raspbian release available at this time (20150505 through NOOBS v1.4.1), the old method modifying the /etc/network/interfaces file isn’t so efficiency as before. In fact, if you modify the /etc/network/interfaces by setting eth0 to static instead of manual (the default setting) your Raspberry Pi will get two IP adresses for the same eth0 interface. This sucks.

The “faulty” is the dhcpcd daemon, which is a DHCP client that seems to be run before the parsing of the /etc/network/interfaces file.

So you have 3 options there:

  1. Setting like before in /etc/network/interfaces then disabling the dhcpcd daemon, with the sudo update-rc.d -f dhcpcd remove command (you can revert back with sudo update-rc.d dhcpcd defaults). But really, don’t do this;
  2. Add a static DHCP entry for your Raspberry Pi in your router/gateway configuration;
  3. Force the dhcpcd daemon to get the IP you like. It’s really the best solution for me.

To implement the latest solution, just sudo nano /etc/dhcpcd.conf then at the end of the file, add the following:

Of course, adjust the IP as you wish. the  192.168.0.1 IP address is referring to my ISP router.

After this modification, restart the network interface or just perform a reboot. Now, your Raspberry Pi will have only one static address!

Note: For those that dislike to set a hard-coded IP, the second solution is the best of course.

Sources:

14 thoughts on “Setting a static IP on Raspberry Pi on Raspbian 20150505

  1. Pingback: IP estática en la Raspberry Pi | Carlini's Blog

  2. Bob

    The dchpcd.conf edit fixed the static IP setup for a fresh Raspbian install. Thanks.

    Reply
  3. Huy

    I tried the interfaces method but failed until I read this article. It works like a miracle!
    Thanks.

    Reply
  4. Pingback: Right way to connect a wireless network and assign a static IP address in Raspbian | FEMRAT的大冰箱

  5. Pingback: Raspberry-PiでVPNサーバーを作る - CGBeginner

  6. SimonH

    Hi,
    Spot on guide – worked perfectly

    And greate that you explained the whys and your recommendation.

    keep up the good work 🙂

    Reply
  7. Vanathi

    Dear all,
    I have set static ip(192.168.1.23) through lan.
    Next
    I have connected my raspberry in my wifi network. its shows ip as 192.168.1.174,
    how can i make this ip as static.

    Reply
  8. IsaacM

    The interfaces method has been failing me but the guide saved me both time and stress. I appreciate.

    Reply
  9. Pingback: Raspberry-PiでVPNサーバーを作る | CGBeginner

  10. Marko

    to set wifi network static instead of interface eth0 use interface wlan.

    Reply
  11. Bart

    Excellent guide, thank you! I had configured /etc/network/interfaces years ago, which worked until I recently got a new router. Thanks to you I got some insight on why it stopped working and I was able to fix it.

    I have read other guides but they didn’t work for me, mainly because they assume their readers use Linux daily. Little additions like “then at the end of the file, add” can make all the difference.

    Speaking of details, “restart the network interface or just perform a reboot” -> the commands for that would have been helpful as well.

    Reply
  12. Pingback: Raspberry pi 4 へOSをインストールしてみたよ!(とりあえずSSH接続できるまで) - クララオンライン|ブログ

Leave a Reply

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

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.