R.A. Epigonos et al.

[Dynamic DNS] ddclient で no-ip.com の更新と Pending Deletion 状態の回避

無料のダイナミック DNS サービスである no-ip.com を使っている。純正のクライアントを使うと、IP アドレスが 30 日間変わらない場合に Pending Deletion 状態になってしまう。適当なアドレスを使って更新を行い、Pending Deletion 状態を回避するために ddclient を使う。

systemd init

インストール時に設定を行う。

# apt-get --no-install-recommends install ddclient
(snip)
Configuring ddclient
--------------------

Please select the dynamic DNS service you are using. If the service you use is not listed, choose "other" and you will be asked for the protocol and the
server name.

  1. www.dyndns.com  2. www.easydns.com  3. www.dslreports.com  4. www.zoneedit.com  5. other

Dynamic DNS service provider: 5


Please enter the name of the server which is providing you with dynamic DNS service (example: members.dyndns.org).

Dynamic DNS server: dynupdate.noip.com


Please select the dynamic DNS update protocol used by your dynamic DNS service provider.

  1. dyndns2  2. dslreports1  3. easydns  4. hammernode1  5. zoneedit1  6. dyndns1

Dynamic DNS update protocol: 1


Please enter the username to use with the dynamic DNS service.

Username for dynamic DNS service: ****************@**********************


Please enter the password to use with the dynamic DNS service.

Password for dynamic DNS service:


Please enter your dynamic DNS service password again to make sure you typed it correctly.

Re-enter password to verify:


Please enter the name of the network interface (eth0/wlan0/ppp0/...) to use for dynamic DNS service.

Network interface used for dynamic DNS service: ppp0


Please enter the list of fully qualified domain names for the local host(s) (for instance, "myname.dyndns.org" with only one host or
"myname1.dyndns.org,myname2.dyndns.org" for two hosts).

DynDNS fully qualified domain names: ************.ddns.net


Selecting previously unselected package ddclient.
(snip)
Processing triggers for systemd (215-17+deb8u4) ...

初回インストール時に生成される設定ファイルを確認すると以下。

# grep -v -e '^$' -e '^#' /etc/default/ddclient
run_dhclient="false"
run_ipup="true"
run_daemon="false"
daemon_interval="300"
# grep -v -e '^$' -e '^#' /etc/ddclient.conf
protocol=dyndns2
use=if, if=ppp0
server=dynupdate.noip.com
login=****************@**********************
password='******************************************'
************.ddns.net

サービスの状態を確認すると以下。

# systemctl status ddclient
● ddclient.service - LSB: Update dynamic domain name service entries
   Loaded: loaded (/etc/init.d/ddclient)
   Active: active (exited) since *** ****-**-** **:**:** ***; 7min ago

*** ** **:**:** ************** ddclient[1324]: To run ddclient as a daemon, please set run_daemon to 'true' in /etc/default/ddclient ... (warning).
*** ** **:**:** ************** ddclient[1324]: .

今回はデーモンとして ddclient を動作させたいので、メッセージに従って /etc/default/ddclient を編集。また protocol=noip に変更するために /etc/ddclient.conf を編集。confファイルの書式は ddclient --help などで詳しく調べられる。

# grep -v -e '^$' -e '^#' /etc/default/ddclient
run_dhclient="false"
run_ipup="false"
run_daemon="true"
daemon_interval="300"
# grep -v -e '^$' -e '^#' /etc/ddclient.conf
protocol=noip
use=if, if=ppp0
server=dynupdate.noip.com
login=****************@**********************
password='******************************************'
************.ddns.net

再起動して、確認。

# systemctl restart ddclient
# systemctl status ddclient
● ddclient.service - LSB: Update dynamic domain name service entries
   Loaded: loaded (/etc/init.d/ddclient)
   Active: active (running) since *** ****-**-** **:**:** ***; 1min 44s ago
  Process: 1387 ExecStop=/etc/init.d/ddclient stop (code=exited, status=0/SUCCESS)
  Process: 1393 ExecStart=/etc/init.d/ddclient start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/ddclient.service
           └─1399 ddclient - sleeping for 200 seconds

Pending Deletion 回避のために以下の設定を crontab に書き込む。

?? ?? * * * /usr/sbin/ddclient -daemon=0 -verbose -noquiet -syslog -ip ***.***.***.***

ログは /var/log/syslog に書き込まれる。以下のとおり、適当なタイミングで ************.ddns.net の IP アドレスが ***.***.***.*** から ???.???.???.??? に変更されていることが確認できる。

# grep 'ddclient' /var/log/syslog
*** ** **:**:** ************** ddclient[1653]: SUCCESS:  updating ************.ddns.net: good: IP address set to ***.***.***.***
*** ** **:**:** ************** ddclient[1399]: SUCCESS:  updating ************.ddns.net: good: IP address set to ???.???.???.???

SystemV init

ddclient のインストール。いくつか聞かれる質問は no-ip の設定には適さないので適当に回答。後から設定ファイルを編集。

# aptitude search ddclient
p   ddclient - address updating utility for dynamic DNS services
# aptitude search ddclient
p   ddclient          - address updating utility for dynamic DNS services
# aptitude install ddclient
The following NEW packages will be installed:
  ddclient libdb4.7{a} libidn11{a} libio-socket-ssl-perl{a} libnet-libidn-perl{a} libnet-ssleay-perl{a} perl{a} perl-modules{a}
0 packages upgraded, 8 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/8436 kB of archives. After unpacking 33.3 MB will be used.
Do you want to continue? [Y/n/?] Y
Selecting previously deselected package libdb4.7.
(Reading database ... 8513 files and directories currently installed.)
Unpacking libdb4.7 (from .../libdb4.7_4.7.25-9_i386.deb) ...
Selecting previously deselected package libidn11.
Unpacking libidn11 (from .../libidn11_1.15-2_i386.deb) ...
Selecting previously deselected package perl-modules.
Unpacking perl-modules (from .../perl-modules_5.10.1-17squeeze5_all.deb) ...
Selecting previously deselected package perl.
Unpacking perl (from .../perl_5.10.1-17squeeze5_i386.deb) ...
Selecting previously deselected package libnet-ssleay-perl.
Unpacking libnet-ssleay-perl (from .../libnet-ssleay-perl_1.36-1_i386.deb) ...
Selecting previously deselected package libio-socket-ssl-perl.
Unpacking libio-socket-ssl-perl (from .../libio-socket-ssl-perl_1.33-1+squeeze1_all.deb) ...
Selecting previously deselected package libnet-libidn-perl.
Unpacking libnet-libidn-perl (from .../libnet-libidn-perl_0.12.ds-1+b1_i386.deb) ...
Selecting previously deselected package ddclient.
Unpacking ddclient (from .../ddclient_3.8.0-11.3_all.deb) ...
Processing triggers for man-db ...
Setting up libdb4.7 (4.7.25-9) ...
Setting up libidn11 (1.15-2) ...
Setting up perl-modules (5.10.1-17squeeze5) ...
Setting up perl (5.10.1-17squeeze5) ...
update-alternatives: using /usr/bin/prename to provide /usr/bin/rename (rename) in auto mode.
Setting up libnet-ssleay-perl (1.36-1) ...
Setting up libio-socket-ssl-perl (1.33-1+squeeze1) ...
Setting up libnet-libidn-perl (0.12.ds-1+b1) ...
Setting up ddclient (3.8.0-11.3) ...
To run ddclient as a daemon, please set run_daemon to 'true' in /etc/default/ddclient ... (warning).

以下のコマンドで再度インストール時に聞かれる質問を繰り返すことができる。

# dpkg-reconfigure ddclient

結局は設定ファイルを直接編集。設定ファイルを以下のように編集。run_ipup と run_daemon は片方が true ならもう一方は false であることに注意。

# grep -v -e '^$' -e '#' /etc/default/ddclient
run_ipup="false"
run_daemon="true"
daemon_interval="300"
$ grep -v -e '^$' -e '#' /etc/ddclient.conf
use=if, if=ppp0
protocol=noip, login='*************@*************', password='*************', *************.no-ip.info

テストでアップデート。失敗する場合は "ddclient -daemon=0 -debug -verbose -noquiet" のようにして原因を探す。

# ddclient -daemon=0
here...**********@********** --> **********
SUCCESS:  updating **********.no-ip.info: good: IP address set to ***.***.***.***

アップデートの内容は以下のファイルにキャッシュされる。

# cat /var/cache/ddclient/ddclient.cache
## ddclient-3.8.0
## last updated at Wed Feb 27 03:23:37 2013 (1361903017)
atime=0,custom=0,host=**********.no-ip.info,ip=***.***.***.***,mtime=1361902810,static=0,status=good,warned-min-error-interval=0,warned-min-interval=0,wtime=30 **********.no-ip.info

再度アップデート。IP アドレスが変わらない場合はアップデート自体行われない。

# ddclient -daemon=0
Use of uninitialized value in string ne at /usr/sbin/ddclient line 2102.
Use of uninitialized value in string ne at /usr/sbin/ddclient line 2102.
Use of uninitialized value in string ne at /usr/sbin/ddclient line 2102.
Use of uninitialized value in string ne at /usr/sbin/ddclient line 2102.
Use of uninitialized value in string ne at /usr/sbin/ddclient line 2102.
Use of uninitialized value in string ne at /usr/sbin/ddclient line 2102.

更新間隔が短すぎるとアップデートされない。

# ddclient -daemon=0
WARNING:  skipping update of **********.no-ip.info from **.**.**.** to ***.***.***.***.
WARNING:   last updated Wed Feb 27 03:58:06 2013.
WARNING:   Wait at least 30 seconds between update attempts.

キャッシュファイルを削除すればアドレスが変わらなくても強制的に更新することが可能。これは abuse と思われる可能性がある。

# rm /var/cache/ddclient/ddclient.cache
# ddclient -daemon=0
here...**********@********** --> **********
WARNING:  updating **********.no-ip.info: nochg: No update required; unnecessary attempts to change to the current address are considered abusive

以前のアップデートと比較して IP アドレスが変わり、かつ、インターバル時間が過ぎていれば、アップデートが行われる。以下は強制的に **.**.**.** にする例。

# ddclient -daemon=0 -ip **.**.**.**
here...**********@********** --> **********
SUCCESS:  updating **********.no-ip.info: good: IP address set to **.**.**.**

デーモンの起動。update-rc.d によるブート時の起動削除と登録。ランレベルに対するシンボリックリンクの確認。

# /etc/init.d/ddclient start
# update-rc.d -f ddclient remove
 Removing any system startup links for /etc/init.d/ddclient ...
   /etc/rc1.d/K20ddclient
   /etc/rc2.d/S20ddclient
   /etc/rc3.d/S20ddclient
   /etc/rc4.d/S20ddclient
   /etc/rc5.d/S20ddclient
# update-rc.d ddclient start 20 2 3 4 5 . stop 20 1 .
 Adding system startup for /etc/init.d/ddclient ...
   /etc/rc1.d/K20ddclient -> ../init.d/ddclient
   /etc/rc2.d/S20ddclient -> ../init.d/ddclient
   /etc/rc3.d/S20ddclient -> ../init.d/ddclient
   /etc/rc4.d/S20ddclient -> ../init.d/ddclient
   /etc/rc5.d/S20ddclient -> ../init.d/ddclient
# ls -la /etc/*/*ddclient*
-rw------- 1 root root  613 Feb 26 23:15 /etc/default/ddclient
-rwxr-xr-x 1 root root 3684 Feb 27 01:13 /etc/init.d/ddclient
lrwxrwxrwx 1 root root   18 Feb 26 23:15 /etc/rc1.d/K20ddclient -> ../init.d/ddclient
lrwxrwxrwx 1 root root   18 Feb 26 23:15 /etc/rc2.d/S20ddclient -> ../init.d/ddclient
lrwxrwxrwx 1 root root   18 Feb 26 23:15 /etc/rc3.d/S20ddclient -> ../init.d/ddclient
lrwxrwxrwx 1 root root   18 Feb 26 23:15 /etc/rc4.d/S20ddclient -> ../init.d/ddclient
lrwxrwxrwx 1 root root   18 Feb 26 23:15 /etc/rc5.d/S20ddclient -> ../init.d/ddclient

crontab に以下の設定を追加。毎日 4 時 5 分に **.**.**.** に更新する例。毎日 1 回 no-ip に通知するアドレスを強制的に変更することで Pending Deletion が回避される。

5 4 * * * /usr/sbin/ddclient -daemon=0 -verbose -noquiet -syslog -ip **.**.**.**

エラーなどの情報は syslog に出力される。cron による強制的な ip アドレスの変更と daemon によるその後の変更が行われていることがわかる。5 分毎 (300 秒毎) の IP アドレス更新チェックにしているが、IP アドレスが変わらなければ、アップデートは行われない。

# date
Wed Feb 27 04:12:13 JST 2013
# zgrep ddclient /var/log/syslog
Feb 27 03:46:51 ****** ddclient[32518]: WARNING:  skipping update of **********.no-ip.info from **.**.**.** to ***.***.***.***.
Feb 27 03:46:51 ****** ddclient[32518]: WARNING:   last updated Wed Feb 27 03:46:21 2013.
Feb 27 03:46:51 ****** ddclient[32518]: WARNING:   Wait at least 30 seconds between update attempts.
Feb 27 03:56:51 ****** ddclient[32518]: SUCCESS:  updating **********.no-ip.info: good: IP address set to ***.***.***.***
Feb 27 04:01:52 ****** ddclient[32518]: SUCCESS:  updating **********.no-ip.info: good: IP address set to ***.***.***.***
Feb 27 04:05:02 ****** /USR/SBIN/CRON[931]: (root) CMD (/usr/sbin/ddclient -daemon=0 -syslog -ip **.**.**.**)
Feb 27 04:05:02 ****** ddclient[933]: SUCCESS:  updating **********.no-ip.info: good: IP address set to **.**.**.**
Feb 27 04:06:53 ****** ddclient[32518]: SUCCESS:  updating **********.no-ip.info: good: IP address set to ***.***.***.***

リファレンス

  1. Dynamic DNS Help and Support - No-IP
  2. No-IP™ DDNS Update API - Request Method
  3. No-IP™ DDNS Update API - Interpret Response

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2010-07-06T01:48:12+09:00
  2. Modified: 2010-07-06T01:48:12+09:00
  3. Generated: 2023-08-27T23:09:12+09:00