User Tools

Site Tools


howtos:systemd_service_waits_for_ip_address

The script in “routes.sh” simply apply some routes to a host but this will not work if the IP hasn't been received from the DHCP server.

This “ExecStartPre” logic delays the start until the gateway responds.

You can also change the IP to a DNS name then it will delay the script until DNS settings are in place.

[Unit]
After=systemd-networkd-wait-online.service

[Service]
ExecStartPre=/bin/sh -c 'until ping -c1 172.16.0.1; do sleep 1; done;'
ExecStart=/usr/local/bin/routes.sh

[Install]
Wants=systemd-networkd-wait-online.service
howtos/systemd_service_waits_for_ip_address.txt · Last modified: 02/08/2023 08:55 by domingo