Skip to content

Instantly share code, notes, and snippets.

@NathanGiesbrecht
Last active June 5, 2024 15:54
Show Gist options
  • Save NathanGiesbrecht/da6560f21e55178bcea7fdd9ca2e39b5 to your computer and use it in GitHub Desktop.
Save NathanGiesbrecht/da6560f21e55178bcea7fdd9ca2e39b5 to your computer and use it in GitHub Desktop.
Systemd Service file for no-ip.com dynamic ip updater
# Simple No-ip.com Dynamic DNS Updater
#
# By Nathan Giesbrecht (http://nathangiesbrecht.com)
#
# 1) Install binary as described in no-ip.com's source file (assuming results in /usr/local/bin)
# 2) Run sudo /usr/local/bin/noip2 -C to generate configuration file
# 3) Copy this file noip2.service to /etc/systemd/system/
# 4) Execute `sudo systemctl daemon-reload`
# 5) Execute `sudo systemctl enable noip2`
# 6) Execute `sudo systemctl start noip2`
#
# systemd supports lots of fancy features, look here (and linked docs) for a full list:
# http://www.freedesktop.org/software/systemd/man/systemd.exec.html
[Unit]
Description=No-ip.com dynamic IP address updater
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
Alias=noip.service
[Service]
# Start main service
ExecStart=/usr/local/bin/noip2
Restart=always
Type=forking
@danielgora
Copy link

Thanks macdja38 for your changes for noip-duc 3.0!

I tested it and it works fine on OpenSuse Tumbleweed 20230503.

A couple minor modifications:

StartLimitIntervalSec was introduced in systemd 230 and must be placed in the [Unit] section, not the [Service] section.

In systemd 229 and earlier you need to use StartLimitInterval and StartLimitBurst in the [Service] section.

See:
https://unix.stackexchange.com/questions/463917/systemds-startlimitintervalsec-and-startlimitburst-never-work
https://lists.freedesktop.org/archives/systemd-devel/2017-July/039255.html

We don't want to be restarting it every 100ms and having it fail if there's a real error condition though. So we'll set RestartSec=5s.
Matching the default no-ip update rate.

Also the default update rate is 5 minutes, not 5 seconds, so the RestartSec should be 'RestartSec=5m'.

Below is an updated version for systemd 230 and later:

# Simple No-ip.com Dynamic DNS Updater
#
# By Nathan Giesbrecht (http://nathangiesbrecht.com)
# Modified by Jake (https://github.com/macdja38)
#
# 1) Install binary as described in no-ip.com's source file (assuming results in /usr/local/bin)
# 2) Run sudo /usr/local/bin/noip -C to generate configuration file
# 3) Copy this file noip2.service to /etc/systemd/system/
# 4) Execute `sudo systemctl daemon-reload`
# 5) Execute `sudo systemctl enable noip`
# 6) Execute `sudo systemctl start noip`
#
# systemd supports lots of fancy features, look here (and linked docs) for a full list:
#   http://www.freedesktop.org/software/systemd/man/systemd.exec.html

[Unit]
Description=No-ip.com dynamic IP address updater
After=network.target
After=syslog.target
StartLimitIntervalSec=0

[Install]
WantedBy=multi-user.target
Alias=noip.service

[Service]
# Start main service
ExecStart=/usr/local/bin/noip-duc -g <domain-name> --username <username> --password <password>
Restart=always
RestartSec=5m

@davidrjonas
Copy link

Author of noip-duc v3 here. Great to see the interest!

I like the restart changes, I'll get them incorporated into the package. In 3.0.0-beta.7 (2023-08-08) it will no longer exit if it cannot resolve hostnames for checking the current IP during start up.

As for the configuration, a better way to handle it so that you don't need to put your password in the unit file it to use environment variables and the systemd Service setting EnvironmentFile. Nearly every command line option has an equivalent env var. You can find them all in the help as well as the README.md.

/etc/noip-duc.env

NOIP_USERNAME=example-username
NOIP_PASSWORD=eXamPle-Pas5w0r&
NOIP_HOSTNAMES=h1.example.com,h2.example.com

Addition to unit file

[Service]
EnvironmentFile=/etc/noip-duc.env

By using EnvironmentFile= instead of EnvironmentFile=- the service will not start unless the file exists, in that way the service will not take any resources unless configured.

Please send in other suggestions or recommendations! I'm so happy to see the interest here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment