dhclient and dhcpcd the real difference

13

5

I can't figure out the difference from just the man pages. I can see what is a daemon and one is a client, but what does that mean practically when using the commands? Also what is the difference between the client and daemon in this case, not just the terms (client and daemon) but functionally wise? EDIT: How are the tasks divided, if the client updates the information on the client, what is the purpose of the daemon. I'm talking about the client daemon in this case dhcpcd not dhcpd. Both come installed by default with some versions of Linux and seem to share the duties of the dhcp client.

NAME dhcpcd - DHCP client daemon

Name
dhclient - Dynamic Host Configuration Protocol Client 

rubixibuc

Posted 2012-02-25T09:53:47.767

Reputation: 1 492

Answers

17

ISC provides dhclient, and as such, it serves as sort of a reference. The more lightweight dhcpcd is somewhat more up to date. Both dhcpcd and dhclient are fully capable DHCP client daemons. Dhclient is not a "one-time" utility:

man dhclient

-w Continue running even if no broadcast interfaces were found. Normally DHCP client will exit if it isn't able to identify any network interfaces to configure. (...)

That is more like the default behavior of dhcpcd.


DHCP has been kind of a moving target, with various vendors (Microsoft in particular) introducing various deviations from the standard.

somebody

Posted 2012-02-25T09:53:47.767

Reputation: 196

2

dhclient is a one-shot client - it reaches out to a server once and only once to request or validate a client's IP address.

In contrast, dhcpcd runs in background and actively manages re-requests after expired lease time etc. pp. without needing to be called again.

BTW do not confuse dhcpcd and dhcpd. The latter is a dhcp server - that is it hands out addresses to network devices when configured to do so. You generally will not use dhcpd on a computer unless you are using that particular computer to manage IP addresses for the entire network.

uSlackr

Posted 2012-02-25T09:53:47.767

Reputation: 8 755

2Downvoting: I disagree. I have seen dhclient remain running, and handle DHCP lease renewals. Maybe your info is accurate for some dhclient software version, but not ISC dhclient (which is typically the reference version). Try checking to see what is running after dhclient seems to be done doing its thing. You may find that, even though it did return the terminal back to a command prompt, it is still running. – TOOGAM – 2015-04-21T12:18:49.297

2

Debian offers a dhcpcd package. The package description reads as follows:

Simple configuration: supports executions of a script when the IP address changes.

dhclient is usually used in this fashion: dhclient -v eth0 or similar - what will happen is that it will send a broadcast out of eth0, and if a DHCP server replies, it will apply information given to eth0. It will then exit. It will not monitor the interface thereafter. I haven't used dhcpcd but I presume that is its purpose.

You would use dhclient if things are messed up and you wanted to fetch a fresh IP from a DHCP server manually. Good tool to have and that is why many distros include it I suppose.

LawrenceC

Posted 2012-02-25T09:53:47.767

Reputation: 63 487

2

It looks like ISC dhclient is not a one-shot client. It's man page says:

The DHCP client will normally run in the foreground until it has 
configured an interface, and then will revert to running in the 
back-ground.

You can use -1 flag to ask dhclient to try only once to get an IP and then exit on fail. From man page:

The -1 flag cause dhclient to try once to get a lease.  If it 
fails, dhclient exits with exit code two.

Vladimir

Posted 2012-02-25T09:53:47.767

Reputation: 21