From 71b9e4ff176e162f4403e479cb40bf0b272462c7 Mon Sep 17 00:00:00 2001 From: Noob Zhang <17194552+zhanghua000@users.noreply.github.com> Date: Sun, 14 Jan 2024 13:05:44 +0800 Subject: [PATCH] Add network-online.target in .service files This helps the daemon work better on IoT devices like RaspberryPi. According to systemd's documentation, `network.target` means there has already been a network manager started, but the network may not be "up". On most PCs this does not matter because the network will turn to "up" almost immidiately. The IoT devices' network interface may not be set up quickly enough, so they may meet that the sing-box daemon is started before network is ready, which results that sing-box cannot find a working route. The workaround of this is restarting sing-box daemon but it absolutely is not the perfect solution. As `network-online.target` must be triggered by network manager after you configured it, I keep `network.target` so there will be no change to those who do not enabled proper trigger service like `NetworkManager-wait-online.service`. See also: https://systemd.io/NETWORK_ONLINE/ --- release/config/sing-box.service | 2 +- release/config/sing-box@.service | 2 +- release/local/sing-box.service | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/release/config/sing-box.service b/release/config/sing-box.service index 76ab695f..7b7a13a8 100644 --- a/release/config/sing-box.service +++ b/release/config/sing-box.service @@ -1,7 +1,7 @@ [Unit] Description=sing-box service Documentation=https://sing-box.sagernet.org -After=network.target nss-lookup.target +After=network.target nss-lookup.target network-online.target [Service] CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH diff --git a/release/config/sing-box@.service b/release/config/sing-box@.service index 423ec458..578ebd1c 100644 --- a/release/config/sing-box@.service +++ b/release/config/sing-box@.service @@ -1,7 +1,7 @@ [Unit] Description=sing-box service Documentation=https://sing-box.sagernet.org -After=network.target nss-lookup.target +After=network.target nss-lookup.target network-online.target [Service] CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH diff --git a/release/local/sing-box.service b/release/local/sing-box.service index 7ff91253..7dfd6f79 100644 --- a/release/local/sing-box.service +++ b/release/local/sing-box.service @@ -1,7 +1,7 @@ [Unit] Description=sing-box service Documentation=https://sing-box.sagernet.org -After=network.target nss-lookup.target +After=network.target nss-lookup.target network-online.target [Service] CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH