Skip to main content
Fix typo
Link
Stefan Lasiewski
  • 20.8k
  • 25
  • 72
  • 86

Systemd-networkd: Run script after DHCP client aqcuiresacquires new address

edited title
Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 238

Systemd-networkd: RundRun script after DHCP client aqcuires new address

Source Link
alexander
  • 91
  • 1
  • 1
  • 2

Systemd-networkd: Rund script after DHCP client aqcuires new address

I am on ubuntu 18.04 server. I need to run a script that updates an IP address on CloudFlare (kind of DynDNS script). In previous versions I could do this with a DHCLIENT exit hooks for the interface enp1s0.

However, systemd now uses their own build-in DHCP client. How can I write a systemd unit that executes my bash script as soon as a new IP address is provided to the DCHP client?

Systemd is managing the interface enp1s0:

#sudo  systemctl status systemd-networkd
● systemd-networkd.service - Network Service
   Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled-runtime; vendor preset: enabled)
   Active: active (running) since Tue 2018-09-18 01:54:16 +08; 10h ago
     Docs: man:systemd-networkd.service(8)
 Main PID: 878 (systemd-network)
   Status: "Processing requests..."
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/systemd-networkd.service
           └─878 /lib/systemd/systemd-networkd

Sep 18 01:54:27 xxx systemd-networkd[878]: enp1s0: Configured