Ordering of Interface Configuration with systemd-networkd
I think we have two problems here:
1/ The removal of your src-route might be due to intermittent carrier loss on the ens3/4 interface. When the interface goes down (even if just briefly) it flushes the IP address and also the src-routes related to this IP address. It then reconfigures the IP via DHCP but lost the src-route that you manually added. Try creating an config override drop-in, e.g.: /etc/systemd/network/10-netplan-ens3.network.d/override.conf
:
[Network]
ConfigureWithoutCarrier=true
IgnoreCarrierLoss=true
2/ systemd-networkd processes the .network files in lexical order, but the DHCP provided IP address is only received asynchronously after the DHCP lease is received. networkd does not block the configuration of the other interfaces (i.e. your tunnel interface) on this DHCP response, therefore the route cannot be added, as that src IP does not yet exist at that point in time.
You say that you have a configuration that always provides you with the same IP address via DHCP. Why don't you specify this very same IP address statically (e.g. addresses: [10.0.16.170/30]
in netplan – or whatever the netmask is)? That way networkd should be able to add your PreferredSource=
address without problem and reconfigure it after carrier was lost.