You are not logged in.

#1 2012-11-06 14:41:02

Beemer
Member
Registered: 2012-05-02
Posts: 13

[Solved] Confused about dhclient and dhcpcd

I've recently switched to systemd and been experiencing and issue where my hostname doesn't resolve properly (sometimes) after startup.  This morning, it wasn't resolving and I have not rebooted since the Nov 2nd.  I had to restart the dhcpcd@eth0 service to fix the issue.

Looking at my system I have NetworkManager running and both dhclient and dhcpcd:


root       439   389  0 Nov02 ?        00:00:01 /usr/sbin/dhclient -d -4 -sf /usr/lib/networkmanager/nm-dhcp-client.action -pf /var/run/dhclient-eth0.pid -lf /var/lib/dhclient/dhclient-ed7f8ec0-c691-49ff-909c-ae6d5a0e26a6-eth0.lease -cf /var/run/nm-dhclient-eth0.conf eth0
root     27298     1  0 07:57 ?        00:00:00 /sbin/dhcpcd -A -q -w eth0

I can see in the logs:

Nov  5 20:42:37 myhostname dhclient: DHCPREQUEST on eth0 to 172.24.0.26 port 67
Nov  5 20:42:38 myhostname dhclient: DHCPACK from 172.24.0.26
Nov  5 20:42:38 myhostname dhclient: can't create /var/lib/dhclient/dhclient-ed7f8ec0-c691-49ff-909c-ae6d5a0e26a6-eth0.lease: No such file or directory
Nov  5 20:42:38 myhostname dhclient: bound to 172.24.1.35 -- renewal in 274326 seconds.
Nov  5 20:42:38 myhostname NetworkManager[389]: <info> (eth0): DHCPv4 state changed bound -> renew
Nov  5 20:42:38 myhostname NetworkManager[389]: <info>   address 172.24.1.35
Nov  5 20:42:38 myhostname NetworkManager[389]: <info>   prefix 22 (255.255.252.0)
Nov  5 20:42:38 myhostname NetworkManager[389]: <info>   gateway 172.24.0.1
Nov  5 20:42:38 myhostname NetworkManager[389]: <info>   nameserver '172.24.0.26'
Nov  5 20:42:38 myhostname NetworkManager[389]: <info>   nameserver '192.168.47.47'
Nov  5 20:42:38 myhostname NetworkManager[389]: <info>   domain name 'mydomain.local'

It appears dhclient didn't renew correctly.  I restart dhcpcd this morning and can see that got me working:

Nov  6 07:57:35 myhostname systemd[1]: Stopping dhcpcd on eth0...
Nov  6 07:57:35 myhostname dhcpcd[27258]: sending signal 1 to pid 466
Nov  6 07:57:35 myhostname dhcpcd[27258]: waiting for pid 466 to exit
Nov  6 07:57:35 myhostname dhcpcd[466]: received SIGHUP, releasing
Nov  6 07:57:35 myhostname dhcpcd[466]: eth0: releasing lease of 172.24.1.35
Nov  6 07:57:35 myhostname dhcpcd[27258]: dhcpcd[27258]: sending signal 1 to pid 466
Nov  6 07:57:35 myhostname dhcpcd[27258]: dhcpcd[27258]: waiting for pid 466 to exit
Nov  6 07:57:35 myhostname dhcpcd[466]: eth0: removing interface
Nov  6 07:57:35 myhostname systemd[1]: dhcpcd@eth0.service: main process exited, code=exited, status=1/FAILURE
Nov  6 07:57:35 myhostname systemd[1]: Unit dhcpcd@eth0.service entered failed state
Nov  6 07:57:35 myhostname systemd[1]: Starting dhcpcd on eth0...
Nov  6 07:57:35 myhostname dhcpcd[27272]: version 5.6.2 starting
Nov  6 07:57:35 myhostname dhcpcd[27272]: eth0: sending IPv6 Router Solicitation
Nov  6 07:57:35 myhostname dhcpcd[27272]: eth0: broadcasting for a lease
Nov  6 07:57:35 myhostname dhcpcd[27272]: eth0: offered 172.24.1.35 from 172.24.0.26
Nov  6 07:57:35 myhostname dhcpcd[27272]: eth0: acknowledged 172.24.1.35 from 172.24.0.26
Nov  6 07:57:35 myhostname dhcpcd[27272]: eth0: leased 172.24.1.35 for 691200 seconds
Nov  6 07:57:35 myhostname dhcpcd[27272]: forked to background, child pid 27298


Thinking that dhclient and dhcpcd shouldn't both be running, I attempted to remove dhclient but couldn't because it was a dependency of NetworkManager.  I also tried stopping the dhcpcd@eth0 service and running dhclient (trying to force a renew) but got the "can't create /var/lib/dhclient/dhclient-ed7f8ec0-c691-49ff-909c-ae6d5a0e26a6-eth0.lease: No such file or directory" error (/var/lib/dhcpcd exists but not /var/lib/dhclient).

In the Arch wiki page for NetworkManager, it has a couple items pertaining to using dhcpcd with NetworkManager so I'm confused as to whether I should be running both dhclient and dhcpcd?  I was under the impression that I should be running one or the other.

Last edited by Beemer (2012-11-06 16:55:38)

Offline

#2 2012-11-06 15:23:19

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: [Solved] Confused about dhclient and dhcpcd

NetworkManager starts dhclient for you, you shouldn't manually start any dhcp client at all.

Offline

#3 2012-11-06 16:43:08

Beemer
Member
Registered: 2012-05-02
Posts: 13

Re: [Solved] Confused about dhclient and dhcpcd

65kid wrote:

NetworkManager starts dhclient for you, you shouldn't manually start any dhcp client at all.

Ok - How do I get this to use dhcpd instead?  I still have a system that's not upgraded to systemd yet and it runs NetworkManager and only has dhcpcd running. 

I've doublechecked the initscripts system and it only has dhcpcd installed and that's what NetworkManager there is using.  I double checked the rc.conf and it starts NetworkManager while blacklists !network and !dhcpcd so NM is the one starting dhcpcd.

I confirmed in the process list as well:

root       355     1  0 07:53 ?        00:00:02 /usr/sbin/NetworkManager
root       546   355  0 07:54 ?        00:00:00 /usr/sbin/dhcpcd -B -K -L -G -c /usr/lib/networkmanager/nm-dhcp-client.action eth0

Last edited by Beemer (2012-11-06 16:43:37)

Offline

#4 2012-11-06 16:51:19

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: [Solved] Confused about dhclient and dhcpcd

NetworkManager recently switched from using dhcpcd to dhclient. If you update NetworkManager on your initscripts system, it will use dhclient there as well. But you will obviously run into other problems because you shouldn't be running initscripts anymore.

I don't know if NetworkManager actually still allows to use dhcpcd, maybe there is a setting, maybe there is a compile flag, maybe you can't do this at all anymore, I don't know. No idea why they switched anyway (especially considering that dhclient depends on crappy old net-tools).

Last edited by 65kid (2012-11-06 16:51:41)

Offline

#5 2012-11-06 16:57:13

Beemer
Member
Registered: 2012-05-02
Posts: 13

Re: [Solved] Confused about dhclient and dhcpcd

I found the solution:

vi /etc/NetworkManager/NetworkManager.conf

add the following line:

dhcp=dhcpcd

Then restart,

systemctl restart NetworkManager

This should stop dhclient and restart using dhcpcd.

Offline

Board footer

Powered by FluxBB