rosede
Posts: 13
Joined: Fri Sep 05, 2014 6:46 pm

dhcpcd causing problems

Mon Sep 19, 2016 1:27 pm

I just upgraded two of my pi's to from Wheezy to Jessie. All of my pi's use static IP addresses.

Previously, to set a static IP I modified /etc/network/interfaces, but I am finding that is no longer the proper way to setup the IP address. I have now learned that I need to setup the static IP information in the dhcpcd.conf file.

The IP address gets setup as assigned, but I'm not able to resolve anything. I see the name server in /etc/resolv.conf file, but still can't resolve anything. As a matter of fact, when I log in, I get the following error, "unable to resolve host "blah blah blah".

I disabled dhcpcd, and set the static IP in the interfaces file, like previously, but now I'm not able to get networking at all. In the upper right corner I see the networking icon with an "x" indicating networking is not working. I hover my mouse over it, and I see "dhcpcd not running". This tells me that dhcpcd is required for networking, why?

Thank you

Daryl

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: dhcpcd causing problems

Mon Sep 19, 2016 3:35 pm

rosede wrote:I just upgraded two of my pi's to from Wheezy to Jessie. All of my pi's use static IP addresses.

Previously, to set a static IP I modified /etc/network/interfaces, but I am finding that is no longer the proper way to setup the IP address. I have now learned that I need to setup the static IP information in the dhcpcd.conf file.

The IP address gets setup as assigned, but I'm not able to resolve anything. I see the name server in /etc/resolv.conf file, but still can't resolve anything. As a matter of fact, when I log in, I get the following error, "unable to resolve host "blah blah blah".

I disabled dhcpcd, and set the static IP in the interfaces file, like previously, but now I'm not able to get networking at all. In the upper right corner I see the networking icon with an "x" indicating networking is not working. I hover my mouse over it, and I see "dhcpcd not running". This tells me that dhcpcd is required for networking, why?
I don't know about within a gui setup, but it is possible to remove dhcpcd from a Jessie lite install and revert to the old way of doing things. I've done it on a couple of pi's where a static IP is required (it's acting as the DHCP server).

I'd check the network status from the command line (open a terminal and use the likes of ifconfig). It may just be the gui tools not reporting correctly even though the network is up.

There is a 2nd question of whether you really need to set a static IP on the Pi itself (most of mine just use DHCP to get their IP). You should be able to access it's name through the zeroconf local dns. You could also look at setting the IP address as a static reservation through the routers config (or where ever your dhcp server is), then let the pi use dhcp normally.

User avatar
CarlRJ
Posts: 598
Joined: Thu Feb 20, 2014 4:00 am
Location: San Diego, California

Re: dhcpcd causing problems

Mon Sep 19, 2016 8:09 pm

rosede wrote:The IP address gets setup as assigned, but I'm not able to resolve anything. I see the name server in /etc/resolv.conf file, but still can't resolve anything. As a matter of fact, when I log in, I get the following error, "unable to resolve host "blah blah blah".
For networking and DNS to work, you need to have, assigned to the appropriate interface, a workable IP address, and netmask, you need to have routing set up with a workable default route (gateway) to reach anything beyond your local subnet (as determined from the IP address and netmask), and you need to have whatever is resolving hostnames configured with the IP addresses of workable DNS servers; this last part is traditionally handled by putting their addresses in /etc/resolv.conf. From your description, it sounds like perhaps your default gateway isn't configured properly, but a mistake in any of these could throw things off.
rosede wrote:I disabled dhcpcd, and set the static IP in the interfaces file, like previously, but now I'm not able to get networking at all. In the upper right corner I see the networking icon with an "x" indicating networking is not working. I hover my mouse over it, and I see "dhcpcd not running". This tells me that dhcpcd is required for networking, why?
The answer to "why" is... because that is how they've set up the system to work. Your question, after disabling dhcpcd, is a bit like pulling out random hoses from under under your car's hood and asking "why did the car maker put this here?" Answer: because it is designed to work in concert with all the other parts to perform the task at hand.

They switched to using dhcpcd (no, I don't know the exact reasoning), and set up the default desktop environment to have a nice widget that could interact with dhcpcd to show available networks and get you attached to one of them. This was a big win in terms of ease-of-use for most Pi users, particularly for their primary focus of education.

The first hit on google, Setting a static IP on Raspberry Pi on Raspbian 20150505, appears to offer a workable solution for a static IP using dhcpcd. It would be helpful if you showed what you added or changed in dhcpcd.conf, as well as the output of ifconfig and netstat -r.

The proper solution, of course, is to configure your DHCP server to assign whatever fixed address you want for the host in question. Configuring individual hosts to force their use of a fixed address is almost always a bad idea (I used to help run a network with around 50,000 hosts on it, we took a rather dim view of such shenanigans). Using DHCP is certainly more resilient - setting a static IP and the associated networking parameters directly on a host makes it brittle: it will stop working if moved to a new environment, and any change to the overall configuration of the network requires changing each and every host so configured. DHCP got us away from that mess, back in the mid-90's. If you're using host-configured static IPs today, you're about 20 years behind the times.

The bigger question would be, why do you feel you need a static IP? Modern versions of Raspbian run Avahi by default, so they're continually broadcasting their current IP addresses via Zeroconf (mDNS). This allows other Raspberry Pi's, Macs, and other machines running modern operating systems (presumably Windows has caught up) to simply connect to "hostname.local", so, assuming your Raspberry Pi still has its default hostname, then "ssh raspberrypi.local" and "scp foo raspberrypi.local:" will work with zero configuration needed (hence the name). I have four Raspberry Pi's on my local network, most of them are headless, and this is how I conduct all interactions with them, addressing them as hostname.local, and they interact with each other the same way.

Heater
Posts: 16092
Joined: Tue Jul 17, 2012 3:02 pm

Re: dhcpcd causing problems

Mon Sep 19, 2016 8:32 pm

Well I never. I have Pi and Debian PC and other boxes around here, for many years, and I have never heard of this Avahi thing. Or perhaps never paid any attention to it. Sure enough I can access my Debian PC with ssh me@debian and Pis at pi@raspberryp3 and so on. From Windows.

Thanks for the heads up.
Memory in C++ is a leaky abstraction .

User avatar
CarlRJ
Posts: 598
Joined: Thu Feb 20, 2014 4:00 am
Location: San Diego, California

Re: dhcpcd causing problems

Mon Sep 19, 2016 11:51 pm

Heater wrote:Well I never. I have Pi and Debian PC and other boxes around here, for many years, and I have never heard of this Avahi thing. Or perhaps never paid any attention to it. Sure enough I can access my Debian PC with ssh me@debian and Pis at pi@raspberryp3 and so on. From Windows.

Thanks for the heads up.
8-) Glad to hear it works from Windows without jumping through any hoops. I've never had a need to test that one. For bonus points, if you put entries in your ~/.ssh/config file on your desktop system (along with the right public/private key files in your ~/.ssh directory), like this:

Code: Select all

Host squirrel squirrel.local
        Hostname squirrel.local
        IdentityFile ~/.ssh/id_ecdsa
        User pi
Then you can "ssh debian" and "ssh raspberryp3" without the username@ or the .local (and without needing a password to get in).

Heater
Posts: 16092
Joined: Tue Jul 17, 2012 3:02 pm

Re: dhcpcd causing problems

Tue Sep 20, 2016 12:19 am

Cool. I use such ssh keys with our cloud servers and other systems.
Memory in C++ is a leaky abstraction .

rosede
Posts: 13
Joined: Fri Sep 05, 2014 6:46 pm

Re: dhcpcd causing problems

Wed Sep 21, 2016 12:37 am

Hello everyone, Sorry for not getting back to this post sooner.

I finally figured out what this issue was, openresolv. openresolv was dynamically updating the /etc/resolv.conf file. No matter what I did to set the /etc/resolvconf.conf file, the /etc/resolv.conf was just getting jacked up. I finally removed openresolv and saw that /etc/resolv.conf was now being generated by dhcpcd. I manually created /etc/resolv.conf.head, set my domain and nameservers, rebooted and all is now good.
CarlRJ wrote:The answer to "why" is... because that is how they've set up the system to work. Your question, after disabling dhcpcd, is a bit like pulling out random hoses from under under your car's hood and asking "why did the car maker put this here?" Answer: because it is designed to work in concert with all the other parts to perform the task at hand.
Carl, That is not true. I am not some noob who just started using Unix. I have 25+ years of Unix background. A common trouble shooting technique is to disable the service. Not to rip it out, but to disable it. By disabling it, and networking not coming up, then the OS is being dependent on this
CarlRJ wrote:The bigger question would be, why do you feel you need a static IP?
This post is was about two different environments; one was work, and the other was personal. Work is a production environment that does not have DHCP. No, these pi's are not running production jobs, but they are on the production network where only static IP exist.

The second is my person environment. I have certain pi's doing certain things, and I want a static IP on these pi's. Other equipment is fine on DHCP, but I want these locked down.
mfa298 wrote: I don't know about within a gui setup, but it is possible to remove dhcpcd from a Jessie lite install and revert to the old way of doing things. I've done it on a couple of pi's where a static IP is required (it's acting as the DHCP server)
One of these pi's is Jessie lite. The one that I was working with when I posted this required the gui, but I don't do anything via the gui. I am an old timer, vi is my best friend. :mrgreen:

Next time I work with Jessie, I'll just rip out dhcpcd and be done with it. I'm not a fan of these packages dynamically updating these files.

Thanks to all who replied.

Daryl

User avatar
popetes
Posts: 10
Joined: Fri Jan 31, 2014 8:14 am

Re: dhcpcd causing problems

Wed Sep 21, 2016 10:51 am

I'm a bit late to the party, but you can lock the resolv.conf file so it doesn't get changed anymore like this:

Code: Select all

chattr +i /etc/resolv.conf
Might need sudo. Saved me from a lot of headache down the road.

User avatar
karrika
Posts: 1125
Joined: Mon Oct 19, 2015 6:21 am
Location: Finland

Re: dhcpcd causing problems

Wed Sep 21, 2016 11:42 am

popetes wrote:I'm a bit late to the party, but you can lock the resolv.conf file so it doesn't get changed anymore like this:

Code: Select all

chattr +i /etc/resolv.conf
Might need sudo. Saved me from a lot of headache down the road.
This might not work. The resolvconf package may make /etc/resolv.conf -> ../run/resolvconf/resolv.conf
chattr +i does not work on links.

Besides, putting the +i flag on files confuses everyone else as the file survives all operations even by the root.

User avatar
popetes
Posts: 10
Joined: Fri Jan 31, 2014 8:14 am

Re: dhcpcd causing problems

Thu Sep 22, 2016 8:14 am

It's working great for me. And there's no 'operations' to be run on the resolv.conf file, once you set your nameservers there's no reason to touch it ever again.

lenoryndweemjarkpree
Posts: 2
Joined: Sat Mar 12, 2016 11:11 am

Re: dhcpcd causing problems

Fri Sep 23, 2016 7:48 pm

rosede wrote:I just upgraded two of my pi's to from Wheezy to Jessie. All of my pi's use static IP addresses.

Previously, to set a static IP I modified /etc/network/interfaces, but I am finding that is no longer the proper way to setup the IP address. I have now learned that I need to setup the static IP information in the dhcpcd.conf file.

The IP address gets setup as assigned, but I'm not able to resolve anything. I see the name server in /etc/resolv.conf file, but still can't resolve anything. As a matter of fact, when I log in, I get the following error, "unable to resolve host "blah blah blah"
Took me ages to solve this problem when I got my new Pis a few months ago. After much agony, the solution was simple, set the DNS servers in /etc/dhcpcd.conf along with the static IP address, viz ...

Code: Select all

interface eth0
static ip_address=10.0.0.4/8
static routers=10.0.0.2
static domain_name_servers=xxx.xxx.xxx.xxx yyy.yyy.yyy.yyy
where xxx.xxx.xxx.xxx yyy.yyy.yyy.yyy are the IP addresses of your ISP's DNS servers, or whatever you previously had in /etc/resolv.conf
and for "ip_address=10.0.0.4/8",
note that the /8 is shorthand for "netmask 255.0.0.0" in the /etc/network/interfaces config
netmask 255.255.0.0 ==> /16
netmask 255.255.255.0 ==> /24

Some notes on this issue ...
Most of the forum threads on this (it's a Debian jessie issue, not a Pi-specific problem, so there are discussions all over various Linux forums), end up recommending deleting dhcpcd. This option can be made to work, but see above, the dhcpcd solution is trivial, once understood

This resource http://elinux.org/RPi_Setting_up_a_static_IP_in_Debian is now obsolete

Hope this helps. It was very frustrating to spend hours reading non-solutions to this, and to eventually discover it only needed one extra line in dhcpcd.conf

Return to “General discussion”