-
-
Save NathanGiesbrecht/da6560f21e55178bcea7fdd9ca2e39b5 to your computer and use it in GitHub Desktop.
# 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 |
Jun 21 12:59:07 raspberrypi systemd[1]: noip2.service: Start request repeated too quickly.
Jun 21 12:59:07 raspberrypi systemd[1]: Failed to start No-ip.com dynamic IP address updater.
Jun 21 12:59:07 raspberrypi systemd[1]: noip2.service: Unit entered failed state.
Jun 21 12:59:07 raspberrypi systemd[1]: noip2.service: Failed with result 'exit-code'.Thanks. Works for me!
If anyone has the mentioned problem, make sure to kill all NOIP processes before starting the service. Or restart the machine.
ps aux | grep noip
Thank you for this! Was racking my brain for over an hour on this one.
Thanks for this, @NathanGiesbrecht - unfortunately no matter what I do I can't get things to work without the 0.0.0.0 error on my Pi4...
Nov 21 16:32:15 pi400 systemd[1]: Starting No-IP Dynamic DNS Update Client...
Nov 21 16:32:15 pi400 noip2[528]: v2.1.9 daemon started with NAT enabled
Nov 21 16:32:15 pi400 noip2[519]: Can't gethostbyname for dynupdate.no-ip.com
Nov 21 16:32:15 pi400 noip2[519]: Can't get our visible IP address from ip1.dynupdate.no-ip.com
Nov 21 16:32:15 pi400 noip2[519]: ! Last_IP_Addr = 0.0.0.0, IP =
Nov 21 16:32:15 pi400 systemd[1]: Started No-IP Dynamic DNS Update Client.
I've tried various options in the [Unit] settings but all to no avail...
Wants=network-online.target
After=network-online.target
Wants=network-online.target systemd-resolved.service
After=network-online.target systemd-resolved.service
After=network.target
After=syslog.target
BindsTo=NetworkManager.service
After=network.target systemd-resolved.service NetworkManager.service
After=network.target systemd-resolved.service
The only thing that worked in the end was the workaround from @msdos - I just changed it from google.com to no-ip.com to make it feel a tiny bit less hacky! Presumably an issue in Rasperry Pi OS/Debian where it's reporting network as being online before it isn't?
Thanks.
with wireguard this worked for me
Wants=wg-quick@wg0.service network-online.target
After=wg-quick@wg0.service network-online.target
[Service]
ExecStartPre=/bin/sh -c 'until ping -c1 google.com; do sleep 1; done;'
Man, you saved me a lot of time. Thanks
thanks you so much no i can use it.
On Ubuntu 20.04 I still get the
Can't gethostbyname for dynupdate.no-ip.com Can't get our visible IP address from ip1.dynupdate.no-ip.com
on boot, despite trying
Wants=network-online.target After=network-online.target
If anyone knows a more permanent solution than the one above from msdos, I'd love to try it.
Adding that line
[Service] ExecStartPre=/bin/sh -c 'until ping -c1 google.com; do sleep 1; done;'
eliminates the error and eventually results in getting the correct IP, but it takes no less than 2 minutes and 10 seconds of trying to ping Google before there's a response. Should my network be taking that long to start up? Once it's running, the ping works at one try if I restart the service. It's just startup that takes literally minutes.
On CentOS7 and adding that ExecStartPre line saved me from these errors:
Nov 21 16:32:15 pi400 noip2[519]: Can't gethostbyname for dynupdate.no-ip.com Nov 21 16:32:15 pi400 noip2[519]: Can't get our visible IP address from ip1.dynupdate.no-ip.com
[Service]
ExecStartPre=/bin/sh -c 'until ping -c1 google.com; do sleep 1; done;'
@msdos you're the boss. Worked like a charm on my Raspberry Pi OS Lite.
I made some modifications to this to support the 3.0 rust duc client.
Compile the 3.0 linux client using the instructions here: https://www.noip.com/support/knowledgebase/install-linux-3-x-dynamic-update-client-duc/#install_from_source
Also changed how the autorestart works as having it fail permanently if networking is not available is far from ideal.
# 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
[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=5s
StartLimitIntervalSec=0
Essentially without StartLimitIntervalSec
if you don't have internet when the service starts it'll enter a permanent failed state.
Setting StartLimitIntervalSec=0
means it'll try forever.
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.
See here for more info systemd/systemd#2416
Not sure if leaving a password in a systemd service is a great idea, if anyone has a better option I'd love to hear it!
(also renamed service to noip from noip2, maybe noip3 or noip-duc would be a better name)
why syslog? it doesn't exist on ubuntu 22 anymore (https://unix.stackexchange.com/questions/255887/how-to-install-enable-syslog-target)
I had the same state and I thought there was something wrong but not necessarily. Then I found this link. (check Systemd Journal Basics section) https://www.loggly.com/ultimate-guide/linux-logging-with-systemd/ It seems this is the current standard for logs with Systemd systems. Inside the link, I found this rather clear statement: With systemd journal, there is no reason for a traditional syslog utility
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
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!
I've created this project ... if someone it's interested, more than welcome! Cheers! https://github.com/felipealfonsog/NoIP-Manager
Thanks, @felipealfonsog! That is very cool.
Thanks. Works for me!
If anyone has the mentioned problem, make sure to kill all NOIP processes before starting the service. Or restart the machine.
ps aux | grep noip