How to install the noip2 on Ubuntu and run via systemd systemctl (noIP Dynamic Update Client)

Often I find instructions from different vendors that are too generic and doesn’t really work the way you want it to. For example, I use https://www.noip.com for my Dynamic DNS updates and I found that the instructions for installing noip2 Dynamic Update Client is lacking clarity and not fit for purpose in latest Ubuntu servers. Ideally noip2 Dynamic DNS Update Client should continually checks for IP address changes in the background and automatically updates the DNS at No-IP whenever it changes. But the instructions are lacking as; if you reboot your server, it doesn’t work anymore because it doesn’t run on startup. This post attempts to fix that problem by installing required packages to run the make command, install noip2 binary, fix file permissions if missing, create an init.d script for service command, create a systemd file so that we can control it via systemd and finally enable it via systemctl. I know, I know I overdid it but it doesn’t hurt and now you will have multiple ways to control it. If you’re familiar with it then you can skip parts to get to the right sections to either use init.d or systemd, so feel free. Now let’s get to it:How to install the noip2 on Ubuntu and run via systemd systemctl (noIP Dynamic Update Client)

Install pre-requisites

SSH to your Linux server and sudo -s yourself to gain root access and install pre-requisites. You can probably skip it if you already have them installed. Once we finish installing the binaries, then we can remove it as well. So no harm done really.

apt install make gcc -y

Change directory

root@ubuntu:~# cd /usr/local/src/
root@ubuntu:/usr/local/src#

Download the noip2 Dynamic Update Client:

root@ubuntu:/usr/local/src# wget http://www.noip.com/client/linux/noip-duc-linux.tar.gz
--2020-11-18 08:25:20-- http://www.noip.com/client/linux/noip-duc-linux.tar.gz
Resolving www.noip.com (www.noip.com)... 8.23.224.107
Connecting to www.noip.com (www.noip.com)|8.23.224.107|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 134188 (131K) [application/x-gzip]
Saving to: ‘noip-duc-linux.tar.gz’

noip-duc-linux.tar. 100%[===================>] 131.04K 113KB/s in 1.2s

2020-11-18 08:25:22 (113 KB/s) - ‘noip-duc-linux.tar.gz’ saved [134188/134188]

Unzip it:

root@ubuntu:/usr/local/src# tar xf noip-duc-linux.tar.gz

Change directory to the folder:

root@ubuntu:/usr/local/src# cd noip-2.1.9-1/
root@ubuntu:/usr/local/src/noip-2.1.9-1#

Install using make:

Install using the make command, this will use GCC to create the binaries and you will then be prompted to log in with your No-IP account username and password

root@ubuntu:/usr/local/src/noip-2.1.9-1# make install
gcc -Wall -g -Dlinux -DPREFIX=\"/usr/local\" noip2.c -o noip2
noip2.c: In function ‘dynamic_update’:
noip2.c:1595:6: warning: variable ‘i’ set but not used [-Wunused-but-set-variable]
int i, x, is_group, retval, response;
^
noip2.c: In function ‘domains’:
noip2.c:1826:13: warning: variable ‘x’ set but not used [-Wunused-but-set-variable]
int x;
^
noip2.c: In function ‘hosts’:
noip2.c:1838:20: warning: variable ‘y’ set but not used [-Wunused-but-set-variable]
int x, y, z;
^
if [ ! -d /usr/local/bin ]; then mkdir -p /usr/local/bin;fi
if [ ! -d /usr/local/etc ]; then mkdir -p /usr/local/etc;fi
cp noip2 /usr/local/bin/noip2
/usr/local/bin/noip2 -C -c /tmp/no-ip2.conf

Auto configuration for Linux client of no-ip.com.

Please enter the login/email string for no-ip.com emailaddress@emaildomain.com
Please enter the password for user 'emailaddress@emaildomain.com' ******

Only one host [noipdomain.ddns.net] is registered to this account.
It will be used.
Please enter an update interval:[30]
Do you wish to run something at successful update?[N] (y/N) N

New configuration file '/tmp/no-ip2.conf' created.

Move configuration file to correct location:

root@ubuntu:/usr/local/src/noip-2.1.9-1# mv /tmp/no-ip2.conf /usr/local/etc/no-ip2.conf

Run as Service or Init.d or Systemd

Now at this point you can just run it and it will run like normal. But the problem is if you reboot your server it won’t start automagically and also noip2 is not running as a service (i.e. via systemctl). That means if you try the following commands, you get errors:

root@ubuntu:/usr/local/etc# systemctl status noip2
Unit noip2.service could not be found.
root@ubuntu:/usr/local/etc# systemctl enable noip2.service
Failed to enable unit: Unit file noip2.service does not exist.

Service/init.d way

So, let’s create a service for it so that we can control it via service command. Fix permissions on files and then drop in an init.d script

root@ubuntu:/usr/local/src/noip-2.1.9-1# chmod 600 /usr/local/etc/no-ip2.conf
root@ubuntu:/usr/local/src/noip-2.1.9-1# chown root:root /usr/local/etc/no-ip2.conf
root@ubuntu:/usr/local/src/noip-2.1.9-1# vi /etc/init.d/noip2.sh

Paste the following in the file and save it

#######################################################
#! /bin/sh
# . /etc/rc.d/init.d/functions # uncomment/modify for your killproc
case "$1" in
start)
echo "Starting noip2."
/usr/local/bin/noip2
;;
stop)
echo -n "Shutting down noip2."
killproc -TERM /usr/local/bin/noip2
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
exit 0
#######################################################

Make it executable and update-rc.d.

root@ubuntu:/usr/local/src/noip-2.1.9-1# sudo chmod +x /etc/init.d/noip2.sh
root@ubuntu:/usr/local/src/noip-2.1.9-1# sudo update-rc.d noip2.sh defaults

Ideally, now you should be able to start the service with service command.

root@ubuntu:/usr/local/src/noip-2.1.9-1# sudo service noip2 status

Systemd or systemctl way

However, if you’re using Ubuntu 15.04 or above, the standard way to control background processes (and much, much more) is systemd. I suggest switching from your init.d script to a systemd unit:

Create noip2 service for systemd

Create the file /etc/systemd/system/noip2.service with the following content (and drop your init.d scripts):

root@ubuntu:/usr/local/src/noip-2.1.9-1# vi /etc/systemd/system/noip2.service

Paste the following and save it.

[Unit]
Description=noip2 service

[Service]
Type=forking
ExecStart=/usr/local/bin/noip2
Restart=always

[Install]
WantedBy=default.target

Little explanation

Since noip2 runs as a daemon, i.e. when you start it, it creates another process that runs in background (so called forking) and the foreground process immediately returns (exits). That’s why the init.d script and the systemd unit fails: They started noip2 just to see it immediately exits. Hence, systemd tried to restart it over and over to no avail. (By default, systemd restarts a process at most 5 times within 10 seconds or so before giving up and leaving it in failed state.). To tell systemd the unit is of type forking we’ve added the line Type=forking to the [Service] section as I just did in the snippet above. This tells systemd to expect the main process to return immediately but instead watch the process spawned (forked) by noip2.

Reload daemon to make systemd aware of noip2

Then issue the following command to make systemd aware of the new unit (systemd caches unit files and this command makes systemd reconsider its cache).

root@ubuntu:/usr/local/src/noip-2.1.9-1# sudo systemctl daemon-reload

Using systemctl to control noip2

Now you can try to start and stop your unit and see its status:

root@ubuntu:/usr/local/src/noip-2.1.9-1# sudo systemctl status noip2
root@ubuntu:/usr/local/src/noip-2.1.9-1# sudo systemctl start noip2
root@ubuntu:/usr/local/src/noip-2.1.9-1# sudo systemctl status noip2
root@ubuntu:/usr/local/src/noip-2.1.9-1# sudo systemctl stop noip2
root@ubuntu:/usr/local/src/noip-2.1.9-1# sudo systemctl status noip2

Enable it during boot:

To have the unit started at boot time you need to enable it:

root@ubuntu:/usr/local/src/noip-2.1.9-1# sudo systemctl enable noip2

Disable it during boot:

To disable autostart at boot time you must disable the unit:

root@ubuntu:/usr/local/src/noip-2.1.9-1# sudo systemctl disable noip2

Most of the time five commands are sufficient to control a units behaviour:

root@ubuntu:/usr/local/src/noip-2.1.9-1# systemctl start $unit # starts a unit NOW
root@ubuntu:/usr/local/src/noip-2.1.9-1# systemctl stop $unit # stops a unit NOW
root@ubuntu:/usr/local/src/noip-2.1.9-1# systemctl status $unit # shows status
root@ubuntu:/usr/local/src/noip-2.1.9-1# systemctl enable $unit # starts a unit at boot time (but not NOW)
root@ubuntu:/usr/local/src/noip-2.1.9-1# systemctl disable $unit # stops autostart (but doesn't stop the unit NOW)

You may also enable autostart and start the unit imediately or disable autostart and stop it at once:

root@ubuntu:/usr/local/src/noip-2.1.9-1# systemctl enable --now $unit # enable and start in one go
root@ubuntu:/usr/local/src/noip-2.1.9-1# systemctl disable --now $unit # disable and stop in one go

Check status:

Let’s check status:

root@ubuntu:/usr/local/src/noip-2.1.9-1# systemctl status noip2
● noip2.service
Loaded: loaded (/etc/systemd/system/noip2.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-11-18 08:43:35 UTC; 1h 56min ago
Main PID: 6798 (noip2)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/noip2.service
└─6798 /usr/local/bin/noip2

Nov 18 08:43:35 ubuntu systemd[1]: Starting noip2.service...
Nov 18 08:43:35 ubuntu noip2[6797]: Recovering dead process 6250 shmem slot
Nov 18 08:43:35 ubuntu noip2[6798]: v2.1.9 daemon started with NAT enabled
Nov 18 08:43:35 ubuntu systemd[1]: Started noip2.service.
Nov 18 08:43:38 ubuntu noip2[6798]: noipdomain.ddns.net was already set to 100.100.101.102
Nov 18 08:43:48 ubuntu systemd[1]: /etc/systemd/system/noip2.service:1: Assignment outside of section. Ignoring.
Nov 18 10:30:52 ubuntu systemd[1]: /etc/systemd/system/noip2.service:1: Assignment outside of section. Ignoring.
root@ubuntu:/usr/local/src/noip-2.1.9-1#

Much better output then using service command.

Journalctl output

This also results in much cleaner journalctl output:

root@ubuntu:~# journalctl -xe
-- Unit noip2.service has begun starting up.
Nov 18 08:43:35 ubuntu systemd[1]: Started noip2.service.
-- Subject: Unit noip2.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit noip2.service has finished starting up.
--
-- The start-up result is RESULT.
Nov 18 08:43:38 ubuntu noip2[6798]: noipdomain.ddns.net was already set to 100.100.101.102

Cleanup the mess

Now that all is done and if you don’t need make or gcc anymore, you can uninstall those and cleanup.

Uninstall gcc and make

root@ubuntu:/usr/local/etc# apt remove make gcc -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  gcc-7 libasan4 libatomic1 libc-dev-bin libc6-dev libcc1-0 libcilkrts5
  libgcc-7-dev libitm1 liblsan0 libmpx2 libquadmath0 libtsan0 libubsan0
  linux-libc-dev manpages-dev
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  gcc make
<----SNIP---->
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

Cleanup unused packages

Hunting for any remaining packages:

root@ubuntu:/usr/local/etc# apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  gcc-7 libasan4 libatomic1 libc-dev-bin libc6-dev libcc1-0 libcilkrts5
  libgcc-7-dev libitm1 liblsan0 libmpx2 libquadmath0 libtsan0 libubsan0
  linux-libc-dev manpages-dev
0 upgraded, 0 newly installed, 16 to remove and 0 not upgraded.
After this operation, 75.1 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 111762 files and directories currently installed.)
<----SNIP---->.
Processing triggers for libc-bin (2.27-3ubuntu1.3) ...
root@ubuntu:/usr/local/etc#

Process Tree output

There … all clean and noip2 running as a service now.

root@ubuntu:~# pstree
systemd─├─VGAuthService
├─accounts-daemon───2*[{accounts-daemon}]
├─atd
├─noip2
<----SNIP---->
root@ubuntu:~#

Quite happy with this. Yes, I realize you don’t need the service command anymore but sometimes I type that by mistake and at least it’s there. Enjoy.

Check Also

Enabling AMD GPU for Hashcat on Kali Linux: A Quick Guide

Enabling AMD GPU for Hashcat on Kali Linux: A Quick Guide

If you’ve encountered an issue where Hashcat initially only recognizes your CPU and not the …

Identifying harmful activity on your captured traffic

This Python script utilises Wireshark or TCPdump to analyse network traffic stored in a specified …

16 comments

  1. You my sir, are a scholar and a legend. Thankyou for this.

  2. Completely agree with hiphopanonymoous, these steps could not have made the fix any easier.

    Thank you!

  3. Very, very helpful! Got noip2 up and running and learned a good deal about systemctl. Thank you!

  4. Excellent write up! Many thanks!

  5. Thanks amazing :) Thanks you so much

  6. Tried both and both exited with errors:

    Sep 07 09:00:43 det systemd[1]: Starting noip2.service…
    Sep 07 09:00:43 det systemd[2610]: noip2.service: Failed to execute command: Exec format error
    Sep 07 09:00:43 det systemd[2610]: noip2.service: Failed at step EXEC spawning /etc/init.d/noip2.sh: Exec format error
    Sep 07 09:00:43 det systemd[1]: noip2.service: Control process exited, code=exited, status=203/EXEC
    Sep 07 09:00:43 det systemd[1]: noip2.service: Failed with result ‘exit-code’.
    Sep 07 09:00:43 det systemd[1]: Failed to start noip2.service.

    • Follow the section for Create noip2 service for systemd:

      sudo vi /etc/systemd/system/noip2.service
      paste the code, then reload daemon.
      sudo systemctl daemon-reload

      Start service:
      sudo systemctl start noip2
      Enable service:
      sudo systemctl enable noip2

    • Looks like a typo/formatting/white-space error. Open the file in a GUI editor like gedit and save it.

  7. when I want to enable the service so it starts on startup I get this:
    Failed to enable unit: Unit /run/systemd/generator.late/noip2.service is transient or generated.

    and when I check it’s status it says:
    ● noip2.service
    Loaded: loaded (/etc/init.d/noip2.sh; generated)
    Active: inactive (dead)
    Docs: man:systemd-sysv-generator(8)

    could someone help me with this?
    thanks in advance

    • Maybe follow the systemd/systemctl priocess instead of init.d script. It seems to be working better for most.

      Follow the section for Create noip2 service for systemd:

      sudo vi /etc/systemd/system/noip2.service
      paste the code, then reload daemon.
      sudo systemctl daemon-reload

      Start service:
      sudo systemctl start noip2
      Enable service:
      sudo systemctl enable noip2

    • I’m a bit late to the party but I had this too. You probably already fixed this but it will most likely be due to you already having noip2 running.

      Use ps -ef | grep noip2 and note the pid number, then kill it using kill with the pid number.

      You should then be good to go, I was.

  8. Hi – just want to say thanks for writing this up.

  9. This is a totally awesome guide. Thanks.

  10. Destin P Carnley Lyon

    So i cant even make it past the wget forsome reason my server cant resolve it im not sure what else to do

  11. I tried both and got this result:

    sudo systemctl status noip2

    × noip2.service – noip2 service
    Loaded: loaded (/etc/systemd/system/noip2.service; enabled; vendor preset:>
    Active: failed (Result: start-limit-hit) since Fri 2023-02-24 06:16:48 AED>
    CPU: 6ms

    Feb 24 06:16:48 powerss systemd[1]: noip2.service: Scheduled restart job, resta>
    Feb 24 06:16:48 powerss systemd[1]: Stopped noip2 service.
    Feb 24 06:16:48 powerss systemd[1]: noip2.service: Start request repeated too q>
    Feb 24 06:16:48 powerss systemd[1]: noip2.service: Failed with result ‘start-li>
    Feb 24 06:16:48 powerss systemd[1]: Failed to start noip2 service.

Leave your solution or comment to help others.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from blackMORE Ops

Subscribe now to keep reading and get access to the full archive.

Continue reading

Privacy Policy on Cookies Usage

Some services used in this site uses cookies to tailor user experience or to show ads.