# systemd-networkd timing problem? no net on boot

## mutiny

I recently ran into an issue after a system update with network no longer active upon system boot. What I found was that if I restart networkd service I would successfully obtain working network configuration. Upon reboot, I looked at networkctl output to see what is happening in failed state:

```
networkctl status

●        State: off

  Online state: unknown

Sep 05 12:52:33 systemd[1]: Starting Network Configuration...

Sep 05 12:52:33 systemd-networkd[1631]: lo: Link UP

Sep 05 12:52:33 systemd-networkd[1631]: lo: Gained carrier

Sep 05 12:52:33 systemd-networkd[1631]: Enumeration completed

Sep 05 12:52:33 systemd[1]: Started Network Configuration.

Sep 05 12:52:33 systemd-networkd[1631]: eth0: Interface name change detected, renamed to eno1.
```

and it would appear as if networkd is attempting to configure the network while it is still named eth0, and therefore no match to the .network config file which specifies eno1.

If I restart the networkd service, it can be seen it successfully matches the eno1 interface and configures:

```
networkctl status

●        State: routable                         

  Online state: online                           

       Address: 192.168.1.12 on eno1

                fe80::76d4:35ff:fee4:a33d on eno1

       Gateway: 192.168.1.1 on eno1

           DNS: 192.168.1.1

Sep 05 12:53:52 systemd[1]: systemd-networkd.service: Deactivated successfully.

Sep 05 12:53:52 systemd[1]: Stopped Network Configuration.

Sep 05 12:53:52 systemd[1]: Starting Network Configuration...

Sep 05 12:53:52 systemd-networkd[2754]: lo: Link UP

Sep 05 12:53:52 systemd-networkd[2754]: lo: Gained carrier

Sep 05 12:53:52 systemd-networkd[2754]: Enumeration completed

Sep 05 12:53:52 systemd[1]: Started Network Configuration.

Sep 05 12:53:52 systemd-networkd[2754]: eno1: Link UP

Sep 05 12:53:55 systemd-networkd[2754]: eno1: Gained carrier

Sep 05 12:53:55 systemd-networkd[2754]: eno1: DHCPv4 address 192.168.1.12/24 via 192.168.1.1
```

Am I doing something incorrectly here in the way I've set up my system configuration? Is there something I can do to fix this seemingly "timing" problem on when interfaces get renamed?

Or is this possible just a systemd bug somehow?

Thanks!

----------

## alamahant

What is your iface nomenclature?

ethx  

OR

enp0sx enox?

If you use kernel parameter "net.ifnames=0 biosdevname=0" you will have  the much preferable ethx format.

Then 

in

/etc/systemd/network

create a file like

eth0.network

And enable 

systemd-networkd

Plz see

https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

----------

## mutiny

 *alamahant wrote:*   

> What is your iface nomenclature?
> 
> ethx  
> 
> OR
> ...

 

It is using predictable device naming, so eno1 seems to be the intended naming as can be seen in the above logs.

I do not use net.ifnames=0 so I would not expect ethx naming.

It truly seems to be a race condition type situation, but I am not really sure.

----------

## blursmurf

Recently decided to set up a Gentoo server and wanted to try using systemd instead of openrc and what do you know, I'm also having the same issue. 

Anyway, did some digging around, it seems like there is a race between udevd renaming and networkd matching the name.

If systemd[1]: Started Network Configuration. starts before the interface is being renamed, then the interface will be an off, unmanaged state waiting for the interface to be "renamed".

```
● 2: enp0s25

                     Link File: /lib/systemd/network/99-default.link

                  Network File: n/a

                          Type: ether

                         State: off (unmanaged)

systemd-networkd[1019]: enp0s25: Interface is under renaming, wait for the interface to be renamed.

```

```
systemd-networkd[1507]: eth0: Link 2 added

systemd-networkd[1507]: eth0: Saved original MTU 1500 (min: 68, max: 9000)

systemd-networkd[1507]: eth0: Saved hardware address: 

systemd-networkd[1507]: eth0: Flags change: +MULTICAST +BROADCAST

systemd-networkd[1507]: eth0: udev initialized link

systemd-networkd[1507]: eth0: State changed: pending -> initialized

systemd-networkd[1507]: eth0: Link state is up-to-date

systemd[1]: Started Network Configuration.

systemd-networkd[1507]: eth0: State changed: initialized -> unmanaged

...

systemd-udevd[1526]: eth0: Policy *path* yields "enp0s25".

...

systemd-networkd[1507]: eth0: Interface name change detected, renamed to enp0s25.

systemd-udevd[1526]: eth0: Network interface 2 is renamed from 'eth0' to 'enp0s25'

systemd-udevd[1526]: eth0: Process '/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/enp0s25 --prefix=/net/ipv4/neigh/enp0s25 --prefix=/n

et/ipv6/conf/enp0s25 --prefix=/net/ipv6/neigh/enp0s25' succeeded.

systemd-networkd[1507]: enp0s25: Interface is under renaming, wait for the interface to be renamed.

```

On a successful startup, 

```

systemd-udevd[1261]: eth0: Policy *path* yields "enp0s25".

systemd-udevd[1261]: eth0: Network interface 2 is renamed from 'eth0' to 'enp0s25'

systemd-udevd[1261]: eth0: Running command "/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/enp0s25 --prefix=/net/ipv4/neigh/enp0s25 --p

refix=/net/ipv6/conf/enp0s25 --prefix=/net/ipv6/neigh/enp0s25"

systemd-udevd[1261]: eth0: Starting '/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/enp0s25 --prefix=/net/ipv4/neigh/enp0s25 --prefix=/

net/ipv6/conf/enp0s25 --prefix=/net/ipv6/neigh/enp0s25'

ystemd-networkd[1329]: enp0s25: Link 2 added

systemd-networkd[1329]: enp0s25: Saved original MTU 1500 (min: 68, max: 9000)

systemd-networkd[1329]: enp0s25: Saved hardware address:

systemd-networkd[1329]: enp0s25: Flags change: +MULTICAST +BROADCAST

systemd-networkd[1329]: enp0s25: udev initialized link

systemd-networkd[1329]: enp0s25: State changed: pending -> initialized

...

systemd[1]: Started Network Configuration.

...

systemd-networkd[1329]: enp0s25: Link state is up-to-date

systemd-networkd[1329]: enp0s25: found matching network '/etc/systemd/network/20-gigabit_wired.network'.

systemd-networkd[1329]: enp0s25: State changed: initialized -> configuring
```

I've added a 5s sleep post starting of systemd-udevd which seems to push the starting of the configuration to after the rename.

```
systemctl edit systemd-udevd
```

```
### Editing /etc/systemd/system/systemd-udevd.service.d/override.conf

### Anything between here and the comment below will become the new contents of the file

[Service]

ExecStartPost=/usr/bin/sleep 5

### Lines below this comment will be discarded
```

Just curious what was the version of systemd you had before the upgrade that broke it and are you using genkernel / kernel with initramfs / kernel?

----------

## AJM

Without wishing to start yet another war, I just can't help commenting on how systemd has brought in this sort of completely unnecessary and unwanted extra churn, then (IME) regularly proceeded to break even the junk it's introduced.

If you need reliable networking on any machine, particularly on a server, I would highly recommend using a tried and tested init system with the "predictable" (there's irony for you) network names disabled (net.ifnames=0 in your kernel command line.)

In my experience on many machines (servers, desktops and laptops) and quite a diverse range of distros, systemd frequently causes networking breakage and fragility which just isn't there with more traditional setups which are invariably rock solid.

----------

