Is there any way to configure a systemd service (e.g. serviceX) to wait for the connmand service to finish configuring network interfaces prior to serviceX running ? From what I understand of systemd, using or relying on the network.target is pointless because that functionality is horribly broken. The system I'm using (BeagleBone Black with Angstrom Linux) uses connman rather than NetworkManager.
3 Answers
According to systemd documentation, all systemd units that need to wait for a working online connection at boot time need to include the following:
[Unit]
...
Wants=network-online.target
After=network-online.target
If you want to be compatible with older systemd versions, you can also use:
[Unit]
...
Wants=network.target network-online.target
After=network.target network-online.target
That's for systemd. With NetworkManager (for completeness, I'm aware you're not using it), this works since the upstream versions 0.9.10 and some distributions including Fedora also worked with older upstream versions.
https://bugzilla.gnome.org/show_bug.cgi?id=728965
As you are using connman instead, you need to check whether connman implements network-online.target
correctly. Checking connman 1.30 source code reveals no appearance of network-online.target
at all, so I must assume that connman is lagging behind. You may want to start a feature request in connman and/or your linux distribution. In that case it would be nice if you added a note about it here.
Basically, with newer systemd versions, a network service that implements network-online.target correctly, and services using the correct dependencies, everything should work out of the box for the user.
According to a comment to the other answer, the Unit section of connman.service
looks as follows:
[Unit]
Description=Connection service
After=syslog.target
There should really be at Before=network.target
, at the least. The After=syslog.target
is redundant with current systemd versions. But full implementation of network-online.target
would be preferred.

- 5,783
- 1
- 31
- 31
-
Your answer didn't solve my problem, but it does provide useful information so thank you. – Alex Marshall May 07 '14 at 14:47
-
As I still see activity in this question, updated towards current situation. – Pavel Šimerda Sep 28 '15 at 07:14
-
This answer does not help for me since my connman may read IPv4=0.0.0.0/0.0.0.0/0.0.0.0 from the user.config file, because in that case network-online.target is never reached. But I need to wait with my user program until connman has read this network configuration but my program also must start independently from whether Linux gets an IP address or not, so I cannot let my service wait for network-online.target. – falkb Aug 05 '19 at 13:24
Wants=network.target network-online.target
and After=network.target network-online.target
seem to be insufficient for Angstrom on the BeagleBone Black at the time of this writing. I also had to add connman.service
to Wants=
in order to get everything to work correctly.

- 10,162
- 15
- 72
- 117
-
Are you sure this is the right way to go. In my opinion, if you are *using* connman, then you have connman.service *enabled* and therefore you don't need `Wants=connman.service` in any of the services that depend on the network. Look at the testing examples in the NM bugzilla ticket I linked. Also it would be good if you could raise this issue with the distribution bug reporting tool. – Pavel Šimerda May 07 '14 at 15:20
-
No, I'm not sure that this is the way to go, but it works, and I don't have time to linger on this and investigate it further as I have other projects that need to be done. The following is the contents of my connman.service file: [Unit] Description=Connection service After=syslog.target [Service] Type=dbus BusName=net.connman ExecStart=/usr/sbin/connmand -n [Install] WantedBy=multi-user.target – Alex Marshall May 12 '14 at 14:36
-
Sure, that's valid. Thanks for the unit file contents. I guess that your solution either works by coincidence or doesn't work at all. IMO connman.service should at least have `Before=network.target`. – Pavel Šimerda May 12 '14 at 14:51
-
The accepted answer is wrong. I have the same problem here but it does not help to add connman.service, which is actually clear because connman.service is Before=network.target. – falkb Aug 05 '19 at 13:14
Following the instructions here, I found that this line (in the [Unit] section of the .service file) worked for me:
Wants=network-online.target #wait for network up. Can slow down script.
I applied this fix for the purpose described, to get opkg upgrade
working correctly, which it now does. I think using network-online
rather than network
may be the trick.

- 2,121
- 3
- 16
- 20
-
-
1To be more clear, this alone (1) doesn't typically solve the problem and (2) the comment after the directive is incorrect. – Pavel Šimerda May 07 '14 at 09:58