# dhcpcd 3.1.5 loops forever when no cable plugged in

## VinzC

Hi.

I've recently upgraded dhcpcd to version 3.1.5 and I now see it doesn't exit after timing out. The man pages say when -t is given dhcpcd exits if it times out while waiting for an IP address (it also says dhcpcd loops forever if the timeout value is zero). But it doesn't exit in my case although I set the time out value to 10 seconds. I have to kill dhcpcd. This problem happens when no cable is plugged in.

Should I file a bug or has anybody already done that?

----------

## mamac

Hi,

I know I will not answer your question but did you try to manage the interface with ifplugd?

I'm not with my Gentoo right now, I'll check which version I use.

----------

## VinzC

 *mamac wrote:*   

> Hi,
> 
> Did you try to manage the interface with ifplugd?

 

No, I didn't - I have a custom network script. But I don't mind to kill dhcpcd manually; what puzzles me is that it doesn't seem to behave as mentioned in the man pages. You can type the command and it'll behave exactly as I described. So there must be a bug somewhere.

----------

## mamac

I use 3.1.5 without problem.

```

FRPC285 ~ # emerge -s dhcpcd

Searching...

[ Results for search key : dhcpcd ]

[ Applications found : 1 ]

*  net-misc/dhcpcd

      Latest version available: 3.1.5

      Latest version installed: 3.1.5

      Size of files: 39 kB

      Homepage:      http://dhcpcd.berlios.de

      Description:   A DHCP client

      License:       GPL-2

```

My /etc/conf.d/net:

```

FRPC285 ~ # cat /etc/conf.d/net

# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

dns_domain_lo="btworld.net"

dhcpcd_eth0="-N"

config_eth0=( "dhcp" )

modules=( "wpa_supplicant" )

wpa_supplicant_eth1="-Dwext"

dhcpcd_eth1="-N"

config_eth1=( "dhcp" )

```

I don't even use the -t option

----------

## VinzC

There is no problem about networking in fact, just that dhcpcd does *not* exit when timing out and the network cable is not plugged in. There is no indication in that it doesn't exit but in the log:

```
...

Oct 16 22:50:03 solo dhcpcd[5440]: eth0: broadcasting for a lease

Oct 16 22:50:13 solo dhcpcd[5440]: eth0: timed out

Oct 16 22:50:13 solo dhcpcd[5440]: eth0: trying to use old lease in `/var/lib/dhcpcd/dhcpcd-eth0.info'

Oct 16 22:50:13 solo dhcpcd[5440]: eth0: checking 169.254.109.154 is available on attached networks

Oct 16 22:50:14 solo dhcpcd[5440]: eth0: adding IP address 169.254.109.154/16

Oct 16 22:50:19 solo dhcpcd[5440]: eth0: broadcasting for a lease

Oct 16 22:50:29 solo dhcpcd[5440]: eth0: timed out

Oct 16 22:50:29 solo dhcpcd[5440]: eth0: trying to use old lease in `/var/lib/dhcpcd/dhcpcd-eth0.info'

Oct 16 22:50:29 solo dhcpcd[5440]: eth0: checking 169.254.109.154 is available on attached networks

Oct 16 22:50:30 solo dhcpcd[5440]: eth0: adding IP address 169.254.109.154/16

Oct 16 22:50:35 solo dhcpcd[5440]: eth0: broadcasting for a lease

Oct 16 22:50:45 solo dhcpcd[5440]: eth0: timed out

Oct 16 22:50:45 solo dhcpcd[5440]: eth0: trying to use old lease in `/var/lib/dhcpcd/dhcpcd-eth0.info'

Oct 16 22:50:45 solo dhcpcd[5440]: eth0: checking 169.254.109.154 is available on attached networks

Oct 16 22:50:46 solo dhcpcd[5440]: eth0: adding IP address 169.254.109.154/16

Oct 16 22:50:51 solo dhcpcd[5440]: eth0: broadcasting for a lease

Oct 16 22:51:01 solo dhcpcd[5440]: eth0: timed out

Oct 16 22:51:01 solo dhcpcd[5440]: eth0: trying to use old lease in `/var/lib/dhcpcd/dhcpcd-eth0.info'

Oct 16 22:51:01 solo dhcpcd[5440]: eth0: checking 169.254.109.154 is available on attached networks

Oct 16 22:51:02 solo dhcpcd[5440]: eth0: adding IP address 169.254.109.154/16

Oct 16 22:51:07 solo dhcpcd[5440]: eth0: broadcasting for a lease

Oct 16 22:51:17 solo dhcpcd[5440]: eth0: timed out

Oct 16 22:51:17 solo dhcpcd[5440]: eth0: trying to use old lease in `/var/lib/dhcpcd/dhcpcd-eth0.info'

Oct 16 22:51:17 solo dhcpcd[5440]: eth0: checking 169.254.109.154 is available on attached networks

Oct 16 22:51:18 solo dhcpcd[5440]: eth0: adding IP address 169.254.109.154/16

...

Oct 19 09:45:17 solo dhcpcd[5439]: eth0: received SIGTERM, stopping

Oct 19 09:45:17 solo dhcpcd[5439]: eth0: deleting IP address 169.254.84.182/16

Oct 19 09:45:17 solo dhcpcd[5439]: eth0: exiting
```

Instead of broadcasting for a lease ever 10 seconds dhcpcd should give up and exit, which it obviously doesn't.

----------

## Bio

I have a similar problem, which happened yesterday when I rebooted my router. I have netplug which notice when the network is going down and up and start/stop my eth0 interface accordingly. But when eth0 is up again DHCP starts, obtain a lease from the DHCP server then loop endlessly :

```

Oct 19 00:26:07 Maverick netplugd[532]: /etc/netplug.d/netplug eth0 out -> pid 532

Oct 19 00:26:09 Maverick dhcpcd[4057]: eth0: received SIGTERM, stopping

Oct 19 00:26:09 Maverick dhcpcd[4057]: eth0: removing default route via 192.168.0.1 metric 0

Oct 19 00:26:09 Maverick dhcpcd[4057]: eth0: deleting IP address 192.168.0.6/24

Oct 19 00:26:09 Maverick dhcpcd[4057]: eth0: exiting

Oct 19 00:26:09 Maverick netplugd[3413]: eth0: state OUTING pid 532 exited status 0

Oct 19 00:26:12 Maverick eth0: Autonegotiation advertising 0x5e1  partner 0x41e1.

Oct 19 00:26:12 Maverick eth0: link up.

Oct 19 00:26:12 Maverick netplugd[3413]: eth0: state INACTIVE flags 0x00001003 UP,BROADCAST,MULTICAST -> 0x00011043 UP,BROADCAST,RUNNING,MULTICAST,10000

Oct 19 00:26:12 Maverick netplugd[1093]: /etc/netplug.d/netplug eth0 in -> pid 1093

Oct 19 00:26:13 Maverick dhcpcd[1506]: eth0: dhcpcd 3.1.5 starting

Oct 19 00:26:13 Maverick dhcpcd[1506]: eth0: broadcasting for a lease

Oct 19 00:26:23 Maverick dhcpcd[1506]: eth0: trying to use old lease in `/var/lib/dhcpcd/dhcpcd-eth0.info'

Oct 19 00:26:23 Maverick dhcpcd[1506]: eth0: probing for an IPV4LL address

Oct 19 00:26:23 Maverick dhcpcd[1506]: eth0: checking 169.254.183.124 is available on attached networks

Oct 19 00:26:24 Maverick dhcpcd[1506]: eth0: adding IP address 169.254.183.124/16

Oct 19 00:26:24 Maverick netplugd[3413]: eth0: state INNING pid 1093 exited status 0

Oct 19 00:26:29 Maverick dhcpcd[1507]: eth0: broadcasting for a lease

Oct 19 00:26:39 Maverick dhcpcd[1507]: eth0: trying to use old lease in `/var/lib/dhcpcd/dhcpcd-eth0.info'

Oct 19 00:26:39 Maverick dhcpcd[1507]: eth0: checking 169.254.183.124 is available on attached networks

Oct 19 00:26:40 Maverick dhcpcd[1507]: eth0: adding IP address 169.254.183.124/16

Oct 19 00:26:45 Maverick dhcpcd[1507]: eth0: broadcasting for a lease

Oct 19 00:26:55 Maverick dhcpcd[1507]: eth0: trying to use old lease in `/var/lib/dhcpcd/dhcpcd-eth0.info'

Oct 19 00:26:55 Maverick dhcpcd[1507]: eth0: checking 169.254.183.124 is available on attached networks

Oct 19 00:26:56 Maverick dhcpcd[1507]: eth0: adding IP address 169.254.183.124/16

Oct 19 00:27:01 Maverick dhcpcd[1507]: eth0: broadcasting for a lease

Oct 19 00:27:11 Maverick dhcpcd[1507]: eth0: trying to use old lease in `/var/lib/dhcpcd/dhcpcd-eth0.info'

Oct 19 00:27:11 Maverick dhcpcd[1507]: eth0: checking 169.254.183.124 is available on attached networks

Oct 19 00:27:12 Maverick dhcpcd[1507]: eth0: adding IP address 169.254.183.124/16

Oct 19 00:27:17 Maverick dhcpcd[1507]: eth0: broadcasting for a lease

Oct 19 00:27:27 Maverick dhcpcd[1507]: eth0: trying to use old lease in `/var/lib/dhcpcd/dhcpcd-eth0.info'

Oct 19 00:27:27 Maverick dhcpcd[1507]: eth0: checking 169.254.183.124 is available on attached networks

Oct 19 00:27:28 Maverick dhcpcd[1507]: eth0: adding IP address 169.254.183.124/16

Oct 19 00:27:33 Maverick dhcpcd[1507]: eth0: broadcasting for a lease

Oct 19 00:27:34 Maverick dhcpcd[1507]: eth0: offered 192.168.0.6 from 192.168.0.1

Oct 19 00:27:34 Maverick dhcpcd[1507]: eth0: received NAK: (null)

Oct 19 00:27:34 Maverick dhcpcd[1507]: eth0: broadcasting for a lease

Oct 19 00:27:34 Maverick dhcpcd[1507]: eth0: offered 192.168.0.6 from 192.168.0.1

Oct 19 00:27:34 Maverick dhcpcd[1507]: eth0: received NAK: (null)

Oct 19 00:27:34 Maverick dhcpcd[1507]: eth0: broadcasting for a lease

Oct 19 00:27:34 Maverick dhcpcd[1507]: eth0: offered 192.168.0.6 from 192.168.0.1

Oct 19 00:27:34 Maverick dhcpcd[1507]: eth0: received NAK: (null)

Oct 19 00:27:34 Maverick dhcpcd[1507]: eth0: broadcasting for a lease

Oct 19 00:27:34 Maverick dhcpcd[1507]: eth0: offered 192.168.0.6 from 192.168.0.1

Oct 19 00:27:35 Maverick dhcpcd[1507]: eth0: received NAK: (null)

Oct 19 00:27:35 Maverick dhcpcd[1507]: eth0: broadcasting for a lease

Oct 19 00:27:35 Maverick dhcpcd[1507]: eth0: offered 192.168.0.6 from 192.168.0.1

Oct 19 00:27:35 Maverick dhcpcd[1507]: eth0: received NAK: (null)

```

Those 3 lines

Oct 19 00:27:35 Maverick dhcpcd[1507]: eth0: broadcasting for a lease

Oct 19 00:27:35 Maverick dhcpcd[1507]: eth0: offered 192.168.0.6 from 192.168.0.1

Oct 19 00:27:35 Maverick dhcpcd[1507]: eth0: received NAK: (null)

repeat endlessly till I manually restart eth0. Obviously the network on my gentoo box is down while this DHCP stuff happens

----------

## UberLord

That should be fixed in dhcpcd-3.1.6

If not, try the version here

http://dev.gentoo.org/~uberlord/dhcpcd-3.1.7_pre2.tar.bz2

Either way, let me know  :Smile: 

----------

## VinzC

Thanks a lot for that quick response, UberLord.

----------

## UberLord

 *VinzC wrote:*   

> Thanks a lot for that quick response, UberLord.

 

Thanks, but is your problem fixed by either of those two versions?

----------

## BrummieJim

yeah, there seem to be a lot of problems with the 3.x versions of dhcpd, just downgrade to a 2.x version using package.mask.

----------

## UberLord

 *BrummieJim wrote:*   

> yeah, there seem to be a lot of problems with the 3.x versions of dhcpd, just downgrade to a 2.x version using package.mask.

 

Have you filed any bugs about your problems with dhcpcd?

----------

## VinzC

Version 3.1.6-r1 fixes the problem. Thanks again.

----------

## VinzC

As an indication, I've had to use the vram flag because the company I'm working for has a DHCP server on Windows 2000, which doesn't fully implement RFC 4361 (the ClientID field probably requires only the MAC address).

My PC got an IP address that was not the one I had reserved on the DHCP. Note while I'm writing this I realized there is a client ID field in the DHCP reservation, which I filled with a value that seemed logical at that time because I didn't know what to enter exactly. The value of that field might just not match the one sent by dhcpcd on my PC. I'll check that next time.

----------

## VinzC

I spoke too early  :Crying or Very sad:  . Then I investigated a little more and I happened to read that dhcpcd now can give an Automatic IP Address if it times out. In that case it doesn't exit unless the -L argument is specified. I then changed my script and added the -L argument when calling dhcpcd and the problem disappeared.

Now I'm not sure whether it's a bug or not but I found my system log filled with dhcpcd renewal attempts every 10 seconds - it's the time-out value I used. That's a little odd  :Rolling Eyes:  .

----------

## UberLord

It should exit when it gets the address.

I've put 3.1.7 into the tree, so please test that version.

----------

## VinzC

I've tested version 3.1.7 but it's the same result: if dhcpcd starts while there is no cable plugged in for eth0 it loops forever a) trying to broadcast for an IP address and b) setting the same APIPA afterwards - as per the log excerpt I posted. Adding -L to the command line arguments is still the only work around I've found.

EDIT: Note there are two distinct processes, one of which is spawned *after* the time out is first logged and which loops forever. It's illustrated here, see the dhcpcd PID:

```
Oct 23 09:02:11 solo dhcpcd[8025]: eth0: dhcpcd 3.1.7 starting

Oct 23 09:02:11 solo dhcpcd[8025]: eth0: hardware address = 00:18:8b:c7:aa:ed

Oct 23 09:02:11 solo dhcpcd[8025]: eth0: broadcasting for a lease

Oct 23 09:02:21 solo dhcpcd[8025]: eth0: timed out

Oct 23 09:02:21 solo dhcpcd[8025]: eth0: trying to use old lease in `/var/lib/dhcpcd/dhcpcd-eth0.info'

Oct 23 09:02:22 solo dhcpcd[8025]: eth0: checking 169.254.84.182 is available on attached networks

Oct 23 09:02:23 solo dhcpcd[8025]: eth0: adding IP address 169.254.84.182/16

Oct 23 09:02:23 solo dhcpcd[8025]: eth0: exiting

Oct 23 09:02:28 solo dhcpcd[8026]: eth0: broadcasting for a lease

... [eth1 is now getting its IP]

Oct 23 09:02:38 solo dhcpcd[8026]: eth0: timed out

Oct 23 09:02:38 solo dhcpcd[8026]: eth0: trying to use old lease in `/var/lib/dhcpcd/dhcpcd-eth0.info'

Oct 23 09:02:38 solo dhcpcd[8026]: eth0: checking 169.254.84.182 is available on attached networks

Oct 23 09:02:39 solo dhcpcd[8026]: eth0: adding IP address 169.254.84.182/16

Oct 23 09:02:44 solo dhcpcd[8026]: eth0: broadcasting for a lease

Oct 23 09:02:54 solo dhcpcd[8026]: eth0: timed out

...
```

Process 8025 times out and exits. But another dhcpcd process, 8026 is spawned immediately after, that loops until I kill dhcpcd. It also looks like dhcpcd spawns a second process *before* if actually exits - I'm running two dhcpcd commands one after the other, one for eth0 the second for eth1, wireless. It is indicated in the log [eth1 is now getting its IP], which means dhcpcd main process, 8025, doesn't quit and return before spawning another process, 8026.

FYI I'm running Gentoo on a Core 2 (Centrino) Duo, amd64 branch.

----------

## toralf

Have a look at the option "-L".

----------

## UberLord

What you are seeing is correct behaviour - it's got a link local address (ipv4ll, apipa, zeroconf, etc) and it's then checks for a dhcp server every 5 seconds.

Basically what happens is when it gets the first address (dhcp or link local) it forks to the background. This is what you are seeing, and is correct behaviour.

 *Quote:*   

> dhcpcd[1507]: eth0: received NAK: (null)

 

That on the other hand you should not be seeing and should be fixed in dhcpcd-3.1.7

----------

## Bio

 *UberLord wrote:*   

>  *Quote:*   dhcpcd[1507]: eth0: received NAK: (null) 
> 
> That on the other hand you should not be seeing and should be fixed in dhcpcd-3.1.7

 

I'm the one who gets the NAK stuff. I got a chance to try dhcpcd 3.1.6 this week end but the problem remained so I'm back to dhcpcd-3.1.5. I will try 3.1.7 ASAP and let you know.

----------

## UberLord

 *Bio wrote:*   

> I'm the one who gets the NAK stuff. I got a chance to try dhcpcd 3.1.6 this week end but the problem remained so I'm back to dhcpcd-3.1.5. I will try 3.1.7 ASAP and let you know.

 

Try and post a log snippet when you have the -d option used - it should log much more info then.

----------

## VinzC

 *UberLord wrote:*   

> What you are seeing is correct behaviour - it's got a link local address (ipv4ll, apipa, zeroconf, etc) and it's then checks for a dhcp server every 5 seconds.
> 
> Basically what happens is when it gets the first address (dhcp or link local) it forks to the background. This is what you are seeing, and is correct behaviour.

 

 :Shocked:  That's frightening! after 24 hours the system log would be filled up with 43,200 lines of garbage after all... You'd argue that I could check for the cable before I run dhcpcd or use netplug or something alike. But don't you agree it's a little too much verbose in this case?

[If dhcpcd were a tow-coloured, she'd only deserve to be slapped...  :Wink:  ]

May I suggest to

decrease the amount of text that is output or

decrease the number of times the same lines are output or

stop jabbering after xyz minutes/seconds/hours/whatever or

be verbose only when things *change*.There have been other examples in the past where gossip services were forced to shut up after a certain amount of time - don't remember which ones exactly.

[And, no, I have nothing against Paris Hilton  :Very Happy:  ]

[And the Troll-Fighters go: ooooooh-ooooooh-ooooh...]

----------

## UberLord

That's a good idea - file a bug for it so I don't forget!

Thanks.

----------

## VinzC

 *UberLord wrote:*   

> That's a good idea - file a bug for it so I don't forget!
> 
> Thanks.

 

Done.

All the best, man  :Smile: 

----------

## Bio

 *UberLord wrote:*   

>  *Bio wrote:*   I'm the one who gets the NAK stuff. I got a chance to try dhcpcd 3.1.6 this week end but the problem remained so I'm back to dhcpcd-3.1.5. I will try 3.1.7 ASAP and let you know. 
> 
> Try and post a log snippet when you have the -d option used - it should log much more info then.

 

OK just did a test with version 3.1.7, problem solved ! No more NAK stuff and dhcpcd obtains a lease.

If you want the log (-d flag enabled) I will post them, though they are rather long.

Thanks

----------

## UberLord

You can email it to me at uberlord@gentoo.org if you like.

----------

## Bio

 *UberLord wrote:*   

> You can email it to me at uberlord@gentoo.org if you like.

 

Done

----------

## UberLord

And it looks fine - thanks. I was half expecting some errors  :Smile: 

----------

## Bio

 *UberLord wrote:*   

> And it looks fine - thanks. I was half expecting some errors 

 

Hey I know what you mean I'm a dev too  :Wink: 

----------

