# [solved]systemd/udev dhcpcd bailing out on boot

## Sulman

A little puzzler. This happens on both my home and work PC, very occasionally. Similar builds of Gentoo running systemd:

```
Aug 27 19:34:28 gentoopc dhcpcd[2966]: dev: loaded udev

Aug 27 19:34:28 gentoopc dhcpcd[2966]: no valid interfaces found

Aug 27 19:34:28 gentoopc dhcpcd[2966]: no interfaces have a carrier

Aug 27 19:34:28 gentoopc dhcpcd[2966]: lo: unsupported interface type 00, falling back to ethernet

Aug 27 19:34:28 gentoopc dhcpcd[2966]: lo: adding address fe80::c51:6906:1cbc:a26f

Aug 27 19:34:28 gentoopc dhcpcd[2966]: if_addaddress6: No such device

Aug 27 19:34:28 gentoopc dhcpcd[2966]: DUID 00:01:00:01:1a:ad:2e:11:00:24:1d:6b:cb:c9

Aug 27 19:34:28 gentoopc dhcpcd[2966]: lo: IAID 00:00:01:00

Aug 27 19:34:28 gentoopc dhcpcd[2966]: sit0: unsupported interface type 308, falling back to ethernet

Aug 27 19:34:28 gentoopc dhcpcd[2966]: sit0: adding address fe80::faa7:fd20:a2f8:24fb

Aug 27 19:34:28 gentoopc dhcpcd[2966]: sit0: waiting for carrier

Aug 27 19:34:28 gentoopc dhcpcd[2966]: enp3s0: adding address fe80::3bf2:8d7b:4805:913f

Aug 27 19:34:28 gentoopc dhcpcd[2966]: enp3s0: waiting for carrier

Aug 27 19:34:28 gentoopc dhcpcd[2966]: enp3s0: waiting for carrier

Aug 27 19:34:28 gentoopc dhcpcd[2966]: enp3s0: removing interface

Aug 27 19:34:28 gentoopc dhcpcd[2966]: sit0: carrier acquired

Aug 27 19:34:29 gentoopc dhcpcd[2966]: sit0: IAID 00:00:00:00

Aug 27 19:34:29 gentoopc dhcpcd[2966]: sit0: soliciting a DHCP lease

Aug 27 19:34:29 gentoopc dhcpcd[2966]: lo: needs a clientid to configure

Aug 27 19:34:29 gentoopc dhcpcd[2966]: lo: soliciting an IPv6 router

Aug 27 19:38:20 gentoopc dhcpcd[2966]: received signal TERM from PID 1, stopping

Aug 27 19:38:20 gentoopc dhcpcd[2966]: sit0: removing interface

Aug 27 19:38:20 gentoopc dhcpcd[2966]: lo: removing interface

Aug 27 19:38:20 gentoopc systemd[1]: dhcpcd.service: main process exited, code=exited, status=1/FAILURE

Aug 27 19:38:20 gentoopc systemd[1]: Unit dhcpcd.service entered failed state.

Aug 27 19:38:20 gentoopc dhcpcd[3715]: version 6.4.3 starting

Aug 27 19:38:20 gentoopc dhcpcd[3715]: dev: loaded udev

Aug 27 19:38:20 gentoopc dhcpcd[3715]: DUID 00:01:00:01:1a:ad:2e:11:00:24:1d:6b:cb:c9

Aug 27 19:38:20 gentoopc dhcpcd[3715]: enp3s0: IAID 1d:6b:cb:c9

Aug 27 19:38:20 gentoopc dhcpcd[3715]: enp3s0: rebinding lease of 10.0.0.200

Aug 27 19:38:21 gentoopc dhcpcd[3715]: enp3s0: soliciting an IPv6 router

Aug 27 19:38:21 gentoopc dhcpcd[3715]: enp3s0: Router Advertisement from fe80::ba9b:c9ff:fecb:e0c2

Aug 27 19:38:21 gentoopc dhcpcd[3715]: enp3s0: adding address 2601:7:8080:870:5b51:9eb3:e232:5d3f/64

Aug 27 19:38:21 gentoopc dhcpcd[3715]: enp3s0: adding route to 2601:7:8080:870::1/64

Aug 27 19:38:21 gentoopc dhcpcd[3715]: enp3s0: adding default route via fe80::ba9b:c9ff:fecb:e0c2

Aug 27 19:38:21 gentoopc dhcpcd[3715]: enp3s0: soliciting a DHCPv6 lease

Aug 27 19:38:25 gentoopc dhcpcd[3715]: enp3s0: leased 10.0.0.200 for 604800 seconds

Aug 27 19:38:25 gentoopc dhcpcd[3715]: enp3s0: adding route to 10.0.0.0/24

Aug 27 19:38:25 gentoopc dhcpcd[3715]: enp3s0: adding default route via 10.0.0.1

Aug 27 19:38:41 gentoopc dhcpcd[3715]: enp3s0: ADV 2601:7:8080:870:aa4d:7f9a:e920:a49b/128 from fe80::ba9b:c9ff:fecb:e0c2

Aug 27 19:38:51 gentoopc dhcpcd[3715]: enp3s0: REPLY6 received from fe80::ba9b:c9ff:fecb:e0c2

Aug 27 19:38:51 gentoopc dhcpcd[3715]: enp3s0: adding address 2601:7:8080:870:aa4d:7f9a:e920:a49b/128

Aug 27 19:38:51 gentoopc dhcpcd[3715]: enp3s0: renew in 144991 seconds, rebind in 231985 seconds

```

Essentially dhcpcd.service bails out having failed to work, because the interface isn't up yet; my gut feeling is udev isn't giving it enough time. 

It's intermittent,  and solved easily by restarting dhcpcd.service. I'm just wondering why this is happening, and it anyone else encounters it?Last edited by Sulman on Wed Sep 10, 2014 2:49 am; edited 1 time in total

----------

## UberLord

```
dhcpcd[2966]: received signal TERM from PID 1, stopping 
```

That's why - systemd told dhcpcd to exit. I have no idea why.

What's a little worrying is that dhcpcd tries to operate on lo and sit0 says it has a carrier (from memory it shouldn't unless instructed AND up).

----------

## Sulman

I thought that was strange too. Systemd was updated by an emerge @world recently so maybe that will fix it.

----------

## zeronullity

[REMOVED UNRELATED ISSUE]Last edited by zeronullity on Fri Sep 05, 2014 10:40 am; edited 3 times in total

----------

## deefster

Have you tried NetworkManager?   I myself used dhcpcd for years under the old rc style boot, but NetworkManager seems to work a bit better with systemd and parallel booting.

----------

## zeronullity

 *deefster wrote:*   

> Have you tried NetworkManager?   I myself used dhcpcd for years under the old rc style boot, but NetworkManager seems to work a bit better with systemd and parallel booting.

 

I can usually work around most problems.. it's just unusual to get so many problems at once when no changes to use flags or config files were made. It's mostly likely a combination of package updates and useflags that didn't cause a problem before, however due to package changes are now causing major issues. I'll just have to solve them one by one until I can get a clear picture of just what happened. idk, just a waste of time regardless.

----------

## UberLord

 *deefster wrote:*   

> Have you tried NetworkManager?   I myself used dhcpcd for years under the old rc style boot, but NetworkManager seems to work a bit better with systemd and parallel booting.

 

dhcpcd works fine on a Debian/systemd system starting very early without any of these reported problems.

I'll try sytemd on my Gentoo installation at some point just to check.

----------

## deefster

I guess YMMV, I myself had issues with for example apache trying to fire up before the network was there.

 *UberLord wrote:*   

>  *deefster wrote:*   Have you tried NetworkManager?   I myself used dhcpcd for years under the old rc style boot, but NetworkManager seems to work a bit better with systemd and parallel booting. 
> 
> dhcpcd works fine on a Debian/systemd system starting very early without any of these reported problems.
> 
> I'll try sytemd on my Gentoo installation at some point just to check.

 

----------

## UberLord

 *deefster wrote:*   

> I guess YMMV, I myself had issues with for example apache trying to fire up before the network was there.

 

NetworkManager-wait-online.service

or

systemd-networkd-wait-online.service

Someone needs to write a dhcpcd variant of those systemd I guess.

EDIT: Or a better thing would be to patch apache to support the IP_FREEBIND socket option when you need to bind to a dynamic address.

----------

## zeronullity

[REMOVED UNRELATED ISSUE]Last edited by zeronullity on Fri Sep 05, 2014 10:40 am; edited 10 times in total

----------

## UberLord

 *UberLord wrote:*   

>  *deefster wrote:*   I guess YMMV, I myself had issues with for example apache trying to fire up before the network was there. 
> 
> NetworkManager-wait-online.service
> 
> or
> ...

 

In the meantime I created a dhcpcd-online applet so someone can easily write a dhcpcd-wait-online.service file for systemd.

----------

## Sulman

Actually, I found a solution on the Arch wiki.

Using just dhcpd.service can cause a race condition, as outlined here: https://wiki.archlinux.org/index.php/Dhcpcd#dhcpcd_and_systemd_network_interfaces

The solution was to copy the service file with the interface name following the @ symbol:

```
cp dhcpcd.service dhcpcd@[interface name].service
```

You have to reload them or trying to enable the new service will fail (systemd is a binary, remember?)

```
systemctl daemon-reload
```

Then enable the new service unit, and disable the original. This ensures that it's bound to that interface and it behaves itself.

----------

## UberLord

 *Sulman wrote:*   

> Actually, I found a solution on the Arch wiki.
> 
> Using just dhcpd.service can cause a race condition, as outlined here: https://wiki.archlinux.org/index.php/Dhcpcd#dhcpcd_and_systemd_network_interfaces
> 
> 

 

dhcpcd has a udev plugin so the race condition can never happen.

If you think it's racing then it's a problem with systemd-udev reporting the wrong things.

----------

## Sulman

 *UberLord wrote:*   

>  *Sulman wrote:*   Actually, I found a solution on the Arch wiki.
> 
> Using just dhcpd.service can cause a race condition, as outlined here: https://wiki.archlinux.org/index.php/Dhcpcd#dhcpcd_and_systemd_network_interfaces
> 
>  
> ...

 

Yes, you're right - that's what the article mentions.

----------

## Sulman

...And it turns out it doesn't work, after many reboot tests. It's blind luck. 

I've given up fighting this brave new world and instead have configured systemd-networkd, as God and/or Lennart Poettering intended.

----------

## UberLord

Is there anymore context you can post?

I just followed the Gentoo guide to installing systemd (running amd64 stable here) and dhcpcd worked perfectly - admittedly it was started after the interfaces were renamed.

So my questions are these

1) Is your systemd modified anyhow?

2) Is your dhcpcd systsemd service modified anyhow?

3) Can you post a full bootlog (enail me privately if you wish) instead of a snippet?

----------

## Sulman

 *UberLord wrote:*   

> Is there anymore context you can post?
> 
> I just followed the Gentoo guide to installing systemd (running amd64 stable here) and dhcpcd worked perfectly - admittedly it was started after the interfaces were renamed.
> 
> So my questions are these
> ...

 

Sure, if I get a moment I'll try and hunt down a few boot logs.

There's nothing unusual, it's literally a wired ethernet connection with dhcpcd.service enabled (I like the simplicity of it) but udev-systemd appears to periodically cause a snag.

----------

