You are not logged in.

#1 2023-04-14 19:47:37

probackup-nl
Member
From: Delft
Registered: 2017-11-15
Posts: 92
Website

[Solved] systemd: For nss-lookup.target to have any effect it needs a

https://wiki.archlinux.org/title/System … work_is_up contains a section with this text:

For nss-lookup.target to have any effect it needs a service that pulls it in via Wants=nss-lookup.target and orders itself before it with Before=nss-lookup.target.

My Arch doesn't use a networking manager. It does use dhcpcd.

It looks like my systemd unit file is started before the nss resolver is functioning.

I used:

[Unit]
Wants=network-online.target nss-lookup.target
After=network.target network-online.target 
Before=nss-lookup.target

Any hint is welcome to how to make my unit file start after the dns-resolver is up and running.

Last edited by probackup-nl (2023-04-18 08:10:45)

Offline

#2 2023-04-14 21:10:01

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 71,649

Re: [Solved] systemd: For nss-lookup.target to have any effect it needs a

If you're using dhcpcd and no local DNS server, you'll likely be more interested in having obtained a lease (because your DNS server is either provided via dhcp or statically configured, but cannot be accessed before having a lease)?

You could loop ping in ExectStartPre until the desired host is reachable, https://bbs.archlinux.org/viewtopic.php … 7#p2090547

Offline

#3 2023-04-15 19:04:46

probackup-nl
Member
From: Delft
Registered: 2017-11-15
Posts: 92
Website

Re: [Solved] systemd: For nss-lookup.target to have any effect it needs a

seth wrote:

You could loop ping in ExectStartPre until the desired host is reachable, https://bbs.archlinux.org/viewtopic.php … 7#p2090547

I tried:

[Unit]
Description=Xwall spam filter
Requires=network-online.target clamav-daemon.socket
After=network.target network-online.target clamav-daemon.socket

[Service]
Type=simple
User=user
Group=user
ExecStartPre=/usr/bin/ping -qW 15 -c1 www.nu.nl
Environment="WINEDLLOVERRIDES=explorer.exe,services.exe=d"
ExecStart=/usr/sbin/wine "/home/user/mbserver.exe"
TimeoutStopSec=120
RestartSec=30
Restart=always

[Install]
WantedBy=multi-user.target

The result seems a problem with the ExecStartPre "ping" command:

# systemctl status xwall.service
● xwall.service - Xwall spam filter
     Loaded: loaded (/etc/systemd/system/xwall.service; enabled; preset: disabled)
     Active: activating (auto-restart) (Result: exit-code) since Sat 2023-04-15 20:43:11 CEST; 23s ago
    Process: 231 ExecStartPre=/usr/bin/ping -qW 15 -c1 www.nu.nl (code=exited, status=2)
        CPU: 22ms

Apr 15 20:43:11 host.domain.tld systemd[1]: xwall.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Apr 15 20:43:11 host.domain.tld systemd[1]: xwall.service: Failed with result 'exit-code'.

Offline

#4 2023-04-15 19:34:34

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 71,649

Re: [Solved] systemd: For nss-lookup.target to have any effect it needs a

The domain can probably not be resolved at this point.
Either ping an IP or, if you really rely on late DNS, don't ping but loop "getent ahosts www.nu.nl" until it succeeds.

Offline

#5 2023-04-17 19:03:25

probackup-nl
Member
From: Delft
Registered: 2017-11-15
Posts: 92
Website

Re: [Solved] systemd: For nss-lookup.target to have any effect it needs a

seth wrote:

loop "getent ahosts www.nu.nl" until it succeeds.

For now I have chosen this getent loop:

ExecStartPre=/usr/bin/bash -c 'until /usr/sbin/getent ahosts test-for-dns-resolve.dataenter.co.at > /dev/null; do sleep 1; done'

Offline

Board footer

Powered by FluxBB