# Solved-New install - systemd not waiting for network carrier

## sedorox

So I'm stuck on this one. I'm building a new Ryzen machine, and all is working thus far, but trying to settle a couple things at boot. Basically I'm finding that systemd/networkd will configure the static ethernet interface, then consider it up and that Network has started. Then followup service (like ntpdate) try to run, but fail as the carrier hasn't come up yet.

I've found systemd-networkd-wait-online, and have added it, but it doesn't seem to trigger, and doesn't show up on 'systemctl':

```

# systemctl is-enabled systemd-networkd-wait-online

enabled

# systemctl | grep networkd

  systemd-networkd.service                                                                                       loaded active running   Network Service                                       

  systemd-networkd.socket                                                                                        loaded active running   Network Service Netlink Socket         

```

If I look on my existing system, it functions as expected, shows enabled, and does show in systemctl output:

```

# systemctl | grep networkd

  systemd-networkd-wait-online.service                                                                  loaded active exited    Wait for Network to be Configured                                            

  systemd-networkd.service                                                                              loaded active running   Network Service                                                              

  systemd-networkd.socket                                                                               loaded active running   Network Service Netlink Socket    

```

On the new system under systemctl list-units -all, it does show, but as inactive/dead:

```

  systemd-networkd-wait-online.service                                                                                    loaded    inactive dead      Wait for Network to be Configured                       

```

Here is the journald output. You can see it's only 3 seconds later that it gets carrier, but it doesn't wait:

```

Aug 10 18:19:33 Rostia kernel: igb 0000:05:00.0 enp5s0: renamed from eth0

Aug 10 18:19:32 Rostia systemd[1]: Reached target Sound Card.

Aug 10 18:19:32 Rostia systemd-udevd[678]: Using default interface naming scheme 'v243'.

Aug 10 18:19:33 Rostia systemd-udevd[678]: ethtool: autonegotiation is unset or enabled, the speed and duplex are not writable.

Aug 10 18:19:33 Rostia systemd-udevd[699]: ethtool: autonegotiation is unset or enabled, the speed and duplex are not writable.

Aug 10 18:19:33 Rostia systemd-udevd[688]: ethtool: autonegotiation is unset or enabled, the speed and duplex are not writable.

Aug 10 18:19:33 Rostia systemd-udevd[685]: ethtool: autonegotiation is unset or enabled, the speed and duplex are not writable.

Aug 10 18:19:33 Rostia systemd-udevd[699]: Using default interface naming scheme 'v243'.

Aug 10 18:19:33 Rostia systemd-udevd[699]: Could not set Alias=, MACAddress= or MTU= on ip6_vti0: Invalid argument

Aug 10 18:19:33 Rostia systemd-udevd[699]: ip6_vti0: Could not apply link config, ignoring: Invalid argument

Aug 10 18:19:33 Rostia systemd-udevd[685]: Using default interface naming scheme 'v243'.

Aug 10 18:19:33 Rostia systemd-udevd[685]: Could not set Alias=, MACAddress= or MTU= on ip6tnl0: Invalid argument

Aug 10 18:19:33 Rostia systemd-udevd[685]: ip6tnl0: Could not apply link config, ignoring: Invalid argument

Aug 10 18:19:33 Rostia systemd-udevd[662]: Using default interface naming scheme 'v243'.

Aug 10 18:19:33 Rostia systemd[1]: Started Flush Journal to Persistent Storage.

Aug 10 18:19:33 Rostia systemd[1]: Starting Create Volatile Files and Directories...

Aug 10 18:19:33 Rostia systemd-tmpfiles[732]: /usr/lib/tmpfiles.d/mysql.conf:1: Line references path below legacy directory /var/run/, updating /var/run/mysqld → /run/mysqld; please update the tmpfiles.d/ drop->

Aug 10 18:19:33 Rostia systemd[1]: Started Create Volatile Files and Directories.

Aug 10 18:19:33 Rostia systemd[1]: Condition check resulted in Rebuild Journal Catalog being skipped.

Aug 10 18:19:33 Rostia systemd[1]: Condition check resulted in Update is Completed being skipped.

Aug 10 18:19:33 Rostia systemd[1]: Starting Update UTMP about System Boot/Shutdown...

Aug 10 18:19:33 Rostia systemd[1]: Started Update UTMP about System Boot/Shutdown.

Aug 10 18:19:33 Rostia systemd[1]: Reached target System Initialization.

Aug 10 18:19:33 Rostia systemd[1]: Started Daily Cleanup of Temporary Directories.

Aug 10 18:19:33 Rostia systemd[1]: Reached target Timers.

Aug 10 18:19:33 Rostia systemd[1]: Listening on D-Bus System Message Bus Socket.

Aug 10 18:19:33 Rostia systemd[1]: Reached target Sockets.

Aug 10 18:19:33 Rostia systemd[1]: Reached target Basic System.

Aug 10 18:19:33 Rostia systemd[1]: Started D-Bus System Message Bus.

Aug 10 18:19:33 Rostia systemd[1]: Starting Login Service...

Aug 10 18:19:33 Rostia systemd-networkd[663]: /etc/systemd/network/enp5s0.network:10: Unknown key name 'Default-Route' in section 'Network', ignoring.

Aug 10 18:19:33 Rostia systemd-networkd[663]: Enumeration completed

Aug 10 18:19:33 Rostia systemd[1]: Started Network Service.

Aug 10 18:19:33 Rostia systemd[1]: Starting Network Name Resolution...

Aug 10 18:19:33 Rostia kernel: 8021q: adding VLAN 0 to HW filter on device enp5s0

Aug 10 18:19:33 Rostia systemd-resolved[750]: Positive Trust Anchors:

Aug 10 18:19:33 Rostia systemd-resolved[750]: . IN DS 19036 8 2 49aac11d7b6f6446702e54a1607371607a1a41855200fd2ce1cdde32f24e8fb5

Aug 10 18:19:33 Rostia systemd-resolved[750]: . IN DS 20326 8 2 e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d

Aug 10 18:19:33 Rostia systemd-resolved[750]: Negative trust anchors: 10.in-addr.arpa 16.172.in-addr.arpa 17.172.in-addr.arpa 18.172.in-addr.arpa 19.172.in-addr.arpa 20.172.in-addr.arpa 21.172.in-addr.arpa 22.1>

Aug 10 18:19:33 Rostia systemd-resolved[750]: Using system hostname 'Rostia'.

Aug 10 18:19:33 Rostia systemd[1]: Started Network Name Resolution.

Aug 10 18:19:33 Rostia systemd[1]: Reached target Network.

Aug 10 18:19:33 Rostia systemd[1]: Reached target Host and Network Name Lookups.

Aug 10 18:19:33 Rostia systemd[1]: Starting Set time via NTP using ntpdate...

Aug 10 18:19:33 Rostia systemd[1]: Starting OpenSSH server daemon...

Aug 10 18:19:33 Rostia systemd[1]: Starting Permit User Sessions...

Aug 10 18:19:33 Rostia ntpdate[758]: 10 Aug 18:19:33 ntpdate[758]: no servers can be used, exiting

Aug 10 18:19:33 Rostia systemd[1]: ntpdate.service: Main process exited, code=exited, status=1/n/a

Aug 10 18:19:33 Rostia systemd[1]: ntpdate.service: Failed with result 'exit-code'.

Aug 10 18:19:33 Rostia systemd[1]: Failed to start Set time via NTP using ntpdate.

Aug 10 18:19:33 Rostia systemd[1]: Reached target System Time Synchronized.

Aug 10 18:19:33 Rostia systemd[1]: Started Network Time Service.

Aug 10 18:19:33 Rostia systemd[1]: Started Permit User Sessions.

Aug 10 18:19:33 Rostia systemd[1]: Started OpenSSH server daemon.

Aug 10 18:19:33 Rostia ntpd[761]: ntpd 4.2.8p13@1.3847-o Fri Aug  9 17:52:50 UTC 2019 (1): Starting

Aug 10 18:19:33 Rostia ntpd[761]: Command line: /usr/sbin/ntpd -g -n

Aug 10 18:19:33 Rostia ntpd[761]: 10 Aug 18:19:33 ntpd[761]: ntpd 4.2.8p13@1.3847-o Fri Aug  9 17:52:50 UTC 2019 (1): Starting

Aug 10 18:19:33 Rostia ntpd[761]: 10 Aug 18:19:33 ntpd[761]: Command line: /usr/sbin/ntpd -g -n

Aug 10 18:19:33 Rostia ntpd[761]: proto: precision = 0.070 usec (-24)

Aug 10 18:19:33 Rostia ntpd[761]: 10 Aug 18:19:33 ntpd[761]: proto: precision = 0.070 usec (-24)

Aug 10 18:19:33 Rostia ntpd[761]: basedate set to 2019-07-28

Aug 10 18:19:33 Rostia ntpd[761]: gps base set to 2019-07-28 (week 2064)

Aug 10 18:19:33 Rostia ntpd[761]: 10 Aug 18:19:33 ntpd[761]: basedate set to 2019-07-28

Aug 10 18:19:33 Rostia ntpd[761]: 10 Aug 18:19:33 ntpd[761]: gps base set to 2019-07-28 (week 2064)

Aug 10 18:19:33 Rostia ntpd[761]: Listen and drop on 0 v6wildcard [::]:123

Aug 10 18:19:33 Rostia ntpd[761]: Listen and drop on 1 v4wildcard 0.0.0.0:123

Aug 10 18:19:33 Rostia ntpd[761]: 10 Aug 18:19:33 ntpd[761]: Listen and drop on 0 v6wildcard [::]:123

Aug 10 18:19:33 Rostia ntpd[761]: 10 Aug 18:19:33 ntpd[761]: Listen and drop on 1 v4wildcard 0.0.0.0:123

Aug 10 18:19:33 Rostia ntpd[761]: Listen normally on 2 lo 127.0.0.1:123

Aug 10 18:19:33 Rostia ntpd[761]: Listen normally on 3 lo [::1]:123

Aug 10 18:19:33 Rostia ntpd[761]: 10 Aug 18:19:33 ntpd[761]: Listen normally on 2 lo 127.0.0.1:123

Aug 10 18:19:33 Rostia ntpd[761]: 10 Aug 18:19:33 ntpd[761]: Listen normally on 3 lo [::1]:123

Aug 10 18:19:33 Rostia ntpd[761]: 10 Aug 18:19:33 ntpd[761]: Listening on routing socket on fd #20 for interface updates

Aug 10 18:19:33 Rostia ntpd[761]: Listening on routing socket on fd #20 for interface updates

Aug 10 18:19:33 Rostia sshd[763]: Server listening on 0.0.0.0 port 22.

Aug 10 18:19:33 Rostia sshd[763]: Server listening on :: port 22.

Aug 10 18:19:33 Rostia ntpd[761]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized

Aug 10 18:19:33 Rostia ntpd[761]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized

Aug 10 18:19:33 Rostia ntpd[761]: 10 Aug 18:19:33 ntpd[761]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized

Aug 10 18:19:33 Rostia systemd-logind[756]: New seat seat0.

Aug 10 18:19:33 Rostia systemd-logind[756]: Watching system buttons on /dev/input/event1 (Power Button)

Aug 10 18:19:33 Rostia systemd-logind[756]: Watching system buttons on /dev/input/event0 (Power Button)

Aug 10 18:19:33 Rostia systemd-logind[756]: Watching system buttons on /dev/input/event3 (Logitech Logitech Illuminated Keyboard)

Aug 10 18:19:33 Rostia systemd-logind[756]: Watching system buttons on /dev/input/event4 (Logitech Logitech Illuminated Keyboard Consumer Control)

Aug 10 18:19:33 Rostia systemd[1]: Started Login Service.

Aug 10 18:19:33 Rostia systemd[1]: Reached target Multi-User System.

Aug 10 18:19:33 Rostia systemd[1]: Reached target Graphical Interface.

Aug 10 18:19:33 Rostia systemd[1]: Startup finished in 21.822s (firmware) + 5.134s (loader) + 8.407s (kernel) + 994ms (userspace) = 36.359s.

Aug 10 18:19:36 Rostia kernel: igb 0000:05:00.0 enp5s0: igb: enp5s0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX/TX

Aug 10 18:19:36 Rostia kernel: IPv6: ADDRCONF(NETDEV_CHANGE): enp5s0: link becomes ready

Aug 10 18:19:36 Rostia systemd-networkd[663]: enp5s0: Gained carrier

Aug 10 18:19:37 Rostia ntpd[761]: Listen normally on 4 enp5s0 10.0.3.20:123

Aug 10 18:19:37 Rostia ntpd[761]: 10 Aug 18:19:37 ntpd[761]: Listen normally on 4 enp5s0 10.0.3.20:123

```

I feel like this is something stupid obvious that I'm missing, but it isn't coming to me. Anyone have any ideas?

(yes, my signature is still correct, this is for the system replacing it:) )

----------

## mike155

If you want to use Systemd, you should rethink how services and daemons work. 

During system booting, services and daemons are started quickly - and much earlier than a stable network is available. 

Do NOT ask: how can I make sure that my daemon / service gets started after the network is up and running. Ask: how can I configure my daemon / service so that it is able to work even if the network has not been started. For example, in case of the OpenSSH daemon: don't use 'ListenAddress <IP-address>', use 'ListenAddress 0.0.0.0' instead.

Look at https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/ for details.

----------

## sedorox

 *mike155 wrote:*   

> If you want to use Systemd, you should rethink how services and daemons work. 
> 
> During system booting, services and daemons are started quickly - and much earlier than a stable network is available. 
> 
> Do NOT ask: how can I make sure that my daemon / service gets started after the network is up and running. Ask: how can I configure my daemon / service so that it is able to work even if the network has not been started. For example, in case of the OpenSSH daemon: don't use 'ListenAddress <IP-address>', use 'ListenAddress 0.0.0.0' instead.
> ...

 

I would agree with you, however, this is for setting the time at boot, so network needs to be up. 

Granted, if it's not, timeout and not start, that's fine.

So I did apparently find a fix via this post.

Basically in /etc/systemd/system/ntpdate.service.d/00gentoo.conf add: 

```

[unit]

Wants=systemd-networkd-wait-online.service

After=systemd-networkd-wait-online.service

```

And then it operates as expected.

----------

