DDNS(No-IP) にグローバル IP を登録する。
クライアントツールと手順は No-IP のサイトを参照。
Dynamic DNS Update Client for Linux
https://www.noip.com/download?page=linux
How to Install the Dynamic Update Client on Linux
https://www.noip.com/support/knowledgebase/installing-the-linux-dynamic-update-client/
クライアントツールのインストール
# cd /usr/local/src
# wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
# tar xzf noip-duc-linux.tar.gz
# cd no-ip-2.1.9
# make
# make install
設定ファイルの作成
# /usr/local/bin/noip2 -C
--------------------------------
Auto configuration for Linux client of no-ip.com.
Please enter the login/email string for no-ip.com email@example.com
Please enter the password for user 'email@example.com' ********
Only one host [example.com] 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)
New configuration file '/usr/local/etc/no-ip2.conf' created.
--------------------------------
クライアントツールの起動
# /usr/local/bin/noip2
と、これで動作はするのだが、サービスとして OS に登録されていないため、
systemd のユニットファイルを作成する。
# vi /etc/systemd/system/noip2.service
--------------------------------クライアントツールのインストール
# cd /usr/local/src
# wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
# tar xzf noip-duc-linux.tar.gz
# cd no-ip-2.1.9
# make
# make install
設定ファイルの作成
# /usr/local/bin/noip2 -C
--------------------------------
Auto configuration for Linux client of no-ip.com.
Please enter the login/email string for no-ip.com email@example.com
Please enter the password for user 'email@example.com' ********
Only one host [example.com] 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)
New configuration file '/usr/local/etc/no-ip2.conf' created.
--------------------------------
クライアントツールの起動
# /usr/local/bin/noip2
と、これで動作はするのだが、サービスとして OS に登録されていないため、
systemd のユニットファイルを作成する。
[Unit]
Description=No-IP update daemon
Wants=network-online.target
After=network-online.target
[Service]
ExecStart=/usr/local/bin/noip2
Restart=always
Type=forking
[Install]
WantedBy=multi-user.target
--------------------------------
自動起動 ON
# systemctl enable noip2
サービス起動
# systemctl start noip2
Systemdを使ってさくっと自作コマンドをサービス化してみる
ユニットファイルを作成する際にはまったのが、以下のエラー。
------------------------------------------------------
# systemctl status noip2
● noip2.service - No-IP update daemon
Loaded: loaded (/etc/systemd/system/noip2.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Fri 2019-04-26 07:40:58 JST; 2min 10s ago
Process: 3404 ExecStart=/usr/local/bin/noip2 (code=exited, status=0/SUCCESS)
Main PID: 3404 (code=exited, status=0/SUCCESS)
Apr 26 07:40:57 localhost.localdomain systemd[1]: Started No-IP update daemon.
Apr 26 07:40:57 localhost.localdomain noip2[3407]: v2.1.9 daemon started with NAT enabled
Apr 26 07:40:57 localhost.localdomain noip2[3407]: Can't gethostbyname for dynupdate.no-ip.com
Apr 26 07:40:57 localhost.localdomain noip2[3407]: Can't get our visible IP address from ip1.dynupdate.no-ip.com
------------------------------------------------------
ネットワーク接続後に noip2 サービスを起動するよう
ユニットファイルで依存関係、起動順序を定義することで解消できた。
Wants=network-online.target
After=network-online.target
以下のサイトが参考になりました。
https://kernhack.hatenablog.com/entry/2014/09/20/110938
https://qiita.com/yunano/items/8636a6dd6becad84920d
と、グローバル IP が更新されても、DDNS のレコードは自動更新されるのですが、
No-IP で登録したホスト名の方は有効期限が 30 日となっており、
期限が切れる前に Web での更新が必要みたいなので、別の DDNS の方が幸せかもしれません。
No-IP がダウンしたときも考えて、もう1つくらい DDNS に登録しようかな。
No-IP の Web 画面を操作するこんなスクリプトもあるようですが、未検証。。
Script to auto renew/confirm noip.com free hosts
https://github.com/loblab/noip-renew
Script to auto renew/confirm noip.com free hosts
https://github.com/loblab/noip-renew
0 件のコメント:
コメントを投稿