# dhclient or dhcpcd ? which is the best?[SOLVED]

## cwc

dhclient or dhcpcd ? Which is the best or does it matter.

I'm running gentoo on a Dell 8000 using both eth0 and ath0.

dhcpcd works much better once it's installed correctly.

----------

## UberLord

I'm the author of dhcpcd-3, so I'm probably a little biased when saying that dhcpcd is the best   :Rolling Eyes: 

dhclient is the most flexible DHCP client there is. However, it's bloated, slow, heavily patched by Gentoo (my work I must admit) and has the occasional hiccup. It also require external binaries such as ifconfig and others.

dhcpcd is not flexible in the slightest, but is a lot smaller and faster. It has no need for any external binaries. It also supports more DHCP features out of the box. dhcpcd also has the occasional hiccup as Gentoo is the main testbase I have   :Twisted Evil: 

dhcpcd-3.3 (currently in heavy development) will be even smaller than dhcpcd-3.2 (by 15k currently) and be a lot more flexible (or allow to be more flexible in the future), hopefully without sacrificing any features.

----------

## cwc

 *UberLord wrote:*   

> I'm the author of dhcpcd-3, so I'm probably a little biased when saying that dhcpcd is the best  
> 
> dhclient is the most flexible DHCP client there is. However, it's bloated, slow, heavily patched by Gentoo (my work I must admit) and has the occasional hiccup. It also require external binaries such as ifconfig and others.
> 
> dhcpcd is not flexible in the slightest, but is a lot smaller and faster. It has no need for any external binaries. It also supports more DHCP features out of the box. dhcpcd also has the occasional hiccup as Gentoo is the main testbase I have  
> ...

 

Wow would I like to put you on my speed dial!

Thanks for the line.  I'm really having trouble with my laptop and eth0 and ath0.  I emerged dhcpcd and I'd prefer to do use that.

But ... I'm finding out I'm more of a nOOb than I thought.  How do I point my nics to dhcpcd?  Dhclient works with ath0 but not eth0.

I've compiled my kernel and I can use both ath0 and eth0 (if I'm lucky, I even can pick up the neighbors WAP).  I just don't have things set correctly.

I need to look at the kernel options more closely and recompile so I bind my nics to the kernel.

error on boot:

* dhcp 

* Running dhcpcd ...

err, etho: timed out

warn, eth0: using IPV$LL address 169.254.42.198 ( yuk!)

Anyway.  If you write back I'd appreciate.  I really want to learn how to do this.

Buy the way.

I teach java, linux (using Fedora core), SQL, A+, Web design and 3d animation at a High School In Pasco,Wa

I have a groupd of students wanting to install Gentoo and I'm  the test monkey.  I've sure learned a lot more about linus since I've

started this Gentoo install on my Dell Ins 8000 p3 800 laptop.

Once again .  thank you.  Off to work I go.

----------

## toralf

Probably you need sth like this :

```
tfoerste@n22 ~/workspace $ grep ^RC_PLUG_SERVICES= /etc/conf.d/rc

RC_PLUG_SERVICES="!*"

```

to give the kernel module(s) enough time to initialize your card(s).

Furthermore this works for me:

```
tfoerste@n22 ~/workspace $ cat /etc/conf.d/net

# /etc/conf.d/net

#

#       LAN

#       dhcp, static ip for local services like apache, ...

#

config_eth0=(

        "dhcp"

        "192.168.0.254/24"

        )

dhcp_eth0="nontp"

dhcpcd_eth0="-L -t 25 -h <hostname>"

#       DSL at home

#

config_ppp0=( "ppp" )

link_ppp0=( "eth0" )

plugins_ppp0=( "pppoe" )

username_ppp0="foo"

password_ppp0=

pppd_ppp0=(

        "defaultroute"

        "usepeerdns"

        "maxfail 1"

)

#       WLAN

#

modules=( "wpa_supplicant" )

wpa_supplicant_ath0="-Dmadwifi"

config_ath0=( "dhcp" )

dhcp_ath0="nontp nosendhost"

dhcpcd_ath0="-L -t 20"

```

BTW dhcpcd works like a charm  :Smile: 

----------

## UberLord

 *cwc wrote:*   

> How do I point my nics to dhcpcd?  Dhclient works with ath0 but not eth0.
> 
> I've compiled my kernel and I can use both ath0 and eth0 (if I'm lucky, I even can pick up the neighbors WAP).  I just don't have things set correctly.
> 
> I need to look at the kernel options more closely and recompile so I bind my nics to the kernel.
> ...

 

Well, if neither dhcpcd or dhclient work on eth0, then we can probably assume a problem with eth0.

Is the cable plugged in and working? You should install ifplugd to manage the cable in/out events for you  :Smile: 

----------

## cwc

I re emerged dhcpcd and eth0 works a bit better.

I also emerged ifplugd.

I do believe I've got a bit a reading to do as per the thread from toralf (thank you!)

I might recompile my kernel and pay closer attention to my nics.  eth0 and ath0

thanks toralg and UberLord

----------

## toralf

 *UberLord wrote:*   

> Well, if neither dhcpcd or dhclient work on eth0, then we can probably assume a problem with eth0.
> 
> Is the cable plugged in and working? You should install ifplugd to manage the cable in/out events for you 

 WIth my ThinkPad T41 I have the problem, that during a boot the eth0 device isn't initialized yet when the net.eth0 services is (automatically) started. Therefore I put the "!* into the rc file and added net.eth0 to the default level instead. Now the kernel already finishes the device before it's being used.

----------

## UberLord

 *toralf wrote:*   

> WIth my ThinkPad T41 I have the problem, that during a boot the eth0 device isn't initialized yet when the net.eth0 services is (automatically) started. Therefore I put the "!* into the rc file and added net.eth0 to the default level instead. Now the kernel already finishes the device before it's being used.

 

Could you explain "isn't initialized yet" a little more?

Also, is eth0 wired or wireless?

----------

## toralf

 *UberLord wrote:*   

> Could you explain "isn't initialized yet" a little more?
> 
> Also, is eth0 wired or wireless?

 I mean eth0. If I let the Gentoo boot scripts automatically start net.eth0 then dhcpcd times out during boot. But I can get an IP address immediately after my sytem has booted.

I suspect that dhcpcd is started to early after udev loaded the e1000 module. Therefore I added net.eth0 to the default level, which gives the e1000 module enough time to complete whatever it is doing.

OTOH I made these experiences with an older kernel + udev  (>1 year ago) - maybe I should give the current system a try ?

----------

## UberLord

Those e1000 cards are nothing but trouble - they don't work good witth ifplugd or netplugd.

BTW, eth0 would also be wireless, which is why I asked  :Smile: 

----------

## cwc

[quote="toralf"]Probably you need sth like this :[code]tfoerste@n22 ~/workspace $ grep ^RC_PLUG_SERVICES= /etc/conf.d/rc

I've yet to update /etc/conf.d/rc.

I can not get dhcpcd to work.  Here is my tty session for ath0. 

I wrote a simple script to connect to my wap essid = "TMA"

I can connect to my neighbor at 192.168.1.1 my WAP is 192.168.0.1  weird.

[code]

tma ~ # iwconfig 

lo        no wireless extensions.

eth1      no wireless extensions.

eth0      no wireless extensions.

wifi0     no wireless extensions.

ath0      IEEE 802.11g  ESSID:"TMA"  Nickname:""

          Mode:Managed  Frequency:2.452 GHz  Access Point: 00:1C:F0:C5:EF:CB   

          Bit Rate:24 Mb/s   Tx-Power:18 dBm   Sensitivity=1/1  

          Retry:off   RTS thr:off   Fragment thr:off

          Encryption key:off

          Power Management:off

          Link Quality=62/70  Signal level=-34 dBm  Noise level=-96 dBm

          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0

          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

tma ~ # 

tma ~ # dhcpcd ath0

err, ath0: timed out

warn, ath0: using IPV4LL address 169.254.115.3

tma ~ # 

tma ~ # dhclient ath0

Internet Systems Consortium DHCP Client V3.0.3-Gentoo-r9

Copyright 2004-2005 Internet Systems Consortium.

All rights reserved.

For info, please visit http://www.isc.org/products/DHCP

wifi0: unknown hardware address type 801

eth1: unknown hardware address type 24

wifi0: unknown hardware address type 801

eth1: unknown hardware address type 24

Listening on LPF/ath0/00:14:6c:fa:b1:46

Sending on   LPF/ath0/00:14:6c:fa:b1:46

Sending on   Socket/fallback

DHCPREQUEST on ath0 to 255.255.255.255 port 67

DHCPREQUEST on ath0 to 255.255.255.255 port 67

DHCPDISCOVER on ath0 to 255.255.255.255 port 67 interval 3

DHCPDISCOVER on ath0 to 255.255.255.255 port 67 interval 6

DHCPDISCOVER on ath0 to 255.255.255.255 port 67 interval 16

DHCPDISCOVER on ath0 to 255.255.255.255 port 67 interval 16

DHCPDISCOVER on ath0 to 255.255.255.255 port 67 interval 10

DHCPDISCOVER on ath0 to 255.255.255.255 port 67 interval 10

No DHCPOFFERS received.

Trying recorded lease 192.168.1.102

PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.

--- 192.168.1.1 ping statistics ---

1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms

Trying recorded lease 192.168.0.2

PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.

--- 192.168.0.1 ping statistics ---

1 packets transmitted, 1 received, 0% packet loss, time 0ms

rtt min/avg/max/mdev = 0.174/0.174/0.174/0.000 ms

bound: immediate renewal.

DHCPREQUEST on ath0 to 255.255.255.255 port 67

tma ~ # iwconfig 

lo        no wireless extensions.

eth1      no wireless extensions.

eth0      no wireless extensions.

wifi0     no wireless extensions.

ath0      IEEE 802.11g  ESSID:"TMA"  Nickname:""

          Mode:Managed  Frequency:2.452 GHz  Access Point: 00:1C:F0:C5:EF:CB   

          Bit Rate:48 Mb/s   Tx-Power:18 dBm   Sensitivity=1/1  

          Retry:off   RTS thr:off   Fragment thr:off

          Encryption key:off

          Power Management:off

          Link Quality=60/70  Signal level=-29 dBm  Noise level=-89 dBm

          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0

          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

tma ~ # ifconfig 

ath0      Link encap:Ethernet  HWaddr 00:14:6C:FA:B1:46  

          inet addr:169.254.115.3  Bcast:169.254.115.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:1409 errors:0 dropped:0 overruns:0 frame:0

          TX packets:238 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:209466 (204.5 Kb)  TX bytes:40952 (39.9 Kb)

eth0      Link encap:Ethernet  HWaddr 00:20:E0:66:0E:96  

          inet addr:192.168.0.2  Bcast:192.168.0.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:1493 errors:0 dropped:0 overruns:0 frame:0

          TX packets:746 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:493629 (482.0 Kb)  TX bytes:159664 (155.9 Kb)

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:6 errors:0 dropped:0 overruns:0 frame:0

          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:672 (672.0 b)  TX bytes:672 (672.0 b)

wifi0     Link encap:UNSPEC  HWaddr 00-14-6C-FA-B1-46-FB-82-00-00-00-00-00-00-00-00  

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:13798 errors:0 dropped:0 overruns:0 frame:1360

          TX packets:440 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:199 

          RX bytes:2814037 (2.6 Mb)  TX bytes:56108 (54.7 Kb)

          Interrupt:10 

[/code]

----------

## cwc

[quote="toralf"]Probably you need sth like this :[code]tfoerste@n22 ~/workspace $ grep ^RC_PLUG_SERVICES= /etc/conf.d/rc

RC_PLUG_SERVICES="!*"

Here is my tty for eth0.

I have no idea why I can use dhclient but not dhcpcd and why my ath0 does not work(previous post)

ath0 does find my ap though.

[code]

tma ~ # ifconfig ath0 down

tma ~ # ifconfig eth0 down

tma ~ # dhcpcd eth0

err, eth0: timed out

warn, eth0: using IPV4LL address 169.254.42.198

tma ~ # dhclient eth0

Internet Systems Consortium DHCP Client V3.0.3-Gentoo-r9

Copyright 2004-2005 Internet Systems Consortium.

All rights reserved.

For info, please visit http://www.isc.org/products/DHCP

eth1: unknown hardware address type 24

eth1: unknown hardware address type 24

Listening on LPF/eth0/00:20:e0:66:0e:96

Sending on   LPF/eth0/00:20:e0:66:0e:96

Sending on   Socket/fallback

DHCPREQUEST on eth0 to 255.255.255.255 port 67

DHCPACK from 192.168.0.1

bound to 192.168.0.2 -- renewal in 37565 seconds.

[/code]

----------

## UberLord

You can use the -I '' option like so

```
dhcpcd -I '' eth0
```

If that works, then your DHCP server isn't RFC compliant.

----------

## cwc

 *UberLord wrote:*   

> You can use the -I '' option like so
> 
> ```
> dhcpcd -I '' eth0
> ```
> ...

 

```
dhcpcd -I '' eth0
```

 did not work.

But dhclient did work.  What is crazy I picked up a WAP from a lynksys router somewhere in my neighborhood.

I've got a dlink 802 11n Router (192.168.0.x) that I can't connect to at this point with ath0.  I used to be able to connect with the same computer.

I've done something wrong somewhere.

----------

## UberLord

Could you try using the -t option? Hopefully it would at least test OK, if not then could I trouble you to get a raw tcpdump of both please?

```
tcpdump -s 0 -i eth0 -w /tmp/dump.pcap
```

While that's running, activate dhclient. Once it has a lease, kill it and start dhcpcd. When that fails, kill it (if running) and try dhclient again.

Once done, email /tmp/dump.pcap to roy@marples.name so I can see why dhcpcd isn't working for you.

Thanks

----------

