手動で ddclient のバージョンを上げる


簡単に

  • v3.8.3 -> v3.9.0 のバージョンアップ
  • EPEL とかにないからソースをダウンロードしてファイルを置き換えよう
  • 設定ファイル系の場所が変わってるっぽかったら変えてあげよう
  • 足りないモジュールがあったら入れてあげよう
  • 何やったかあんまり覚えてなくて割と雑です

CloudFlare API v1 EOL

ddclient + CloudFlare DNS で自宅サーバーを Dynamic DNS で運用していましたが、
ddclient v3.8.3 が使っている CloudFlare API v1 が 2018 年 6 月で終了しました。
個人的には、最近はもっぱら OPEN IPv6 ダイナミック DNS for フレッツ・光ネクスト を使っているので
動かなくなった後はしばらく放置していました。

先日、自宅でブレーカー落ちちゃった事件が発生したので、
復電後の外部からの接続確認でついでに ddclient + CloudFlare DNS も直してみることにしました。

手順

今回の環境

  • OS: RHEL 7.6
  • ddclient v3.8.3 を EPEL 経由でインストールした

ddclient v3.9.0

ddclient は v3.9.0 で CloudFlare API v4 に対応しました。
なんと 2018 年 8 月にリリースされていたようです。

自宅サーバには EPEL でインストールしたのでもうリポジトリに降ってきていることを期待してたいのですが、
まだ v3.9.0 は降ってきていないようです。

yum info ddclient
$ sudo yum info ddclient
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
Installed Packages
Name        : ddclient
Arch        : noarch
Version     : 3.8.3
Release     : 2.el7
Size        : 212 k
Repo        : installed
From repo   : epel
Summary     : Client to update dynamic DNS host entries
URL         : http://ddclient.sourceforge.net/
License     : GPLv2+
Description : ddclient is a Perl client used to update dynamic DNS entries for accounts
            : on many different dynamic DNS services. Features include: Operating as a
            : daemon, manual and automatic updates, static and dynamic updates, optimized
            : updates for multiple addresses, MX, wildcards, abuse avoidance, retrying
            : the failed updates and sending update status to syslog and through e-mail.

ソースをダウンロードしてファイルを置換

というわけで、ソースをダウンロードしてファイルを置き換えて更新します。
ddclient はシングルスクリプトなので楽ですね。
ちなみに、 v3.9.0 で ddclient.conf のパスが変わったようです。

  • v3.8.3: /etc/ddclient.conf
  • v3.9.0: /etc/ddclient/ddclient.conf
manual update ddclient
$ curl -L -o ddclient-3.9.0.tar.gz https://github.com/ddclient/ddclient/archive/v3.9.0.tar.gz
$ tar xvf ddclient-3.9.0.tar.gz
ddclient-3.9.0/
ddclient-3.9.0/.gitignore
ddclient-3.9.0/COPYING
ddclient-3.9.0/COPYRIGHT
ddclient-3.9.0/ChangeLog
ddclient-3.9.0/Changelog.old
ddclient-3.9.0/README.cisco
ddclient-3.9.0/README.md
ddclient-3.9.0/README.ssl
ddclient-3.9.0/RELEASENOTE
ddclient-3.9.0/TODO
ddclient-3.9.0/UPGRADE
ddclient-3.9.0/ddclient
ddclient-3.9.0/sample-ddclient-wrapper.sh
ddclient-3.9.0/sample-etc_cron.d_ddclient
ddclient-3.9.0/sample-etc_ddclient.conf
ddclient-3.9.0/sample-etc_dhclient-exit-hooks
ddclient-3.9.0/sample-etc_dhcpc_dhcpcd-eth0.exe
ddclient-3.9.0/sample-etc_ppp_ip-up.local
ddclient-3.9.0/sample-etc_rc.d_init.d_ddclient
ddclient-3.9.0/sample-etc_rc.d_init.d_ddclient.alpine
ddclient-3.9.0/sample-etc_rc.d_init.d_ddclient.lsb
ddclient-3.9.0/sample-etc_rc.d_init.d_ddclient.redhat
ddclient-3.9.0/sample-etc_rc.d_init.d_ddclient.ubuntu
ddclient-3.9.0/sample-get-ip-from-fritzbox
$ sudo systemctl stop ddclient
$ sudo cp ddclient-3.9.0/ddclient /sbin/ddclient
$ sudo cp ddclient-3.9.0/sample-etc_ddclient.conf /etc/ddclient/ddclient.conf

設定ファイル更新

CloudFlare DNS の場合は微妙にディレクティブが変わってました。
server がなくなって ttl が追加されていました。

/etc/ddclient/ddclient.conf
  #protocol=cloudflare,        \
  #zone=domain.tld,            \
- #server=www.cloudflare.com,  \ # v3.8.3
+ #ttl=1,                      \ # v3.9.0
  #login=your-login-email,     \
  #password=APIKey             \
  #domain.tld,my.domain.tld

あと起動時に /var/run/ddclient.pid が作れねーよって怒られたので、
パーミッションやユーザを変えるとか設定を元に戻すとか適当に対応してください。
ぼくは v3.8.3 の頃の設定に戻しました。

/etc/ddclient/ddclient.conf
- pid=/var/run/ddclient.pid
+ pid=/var/run/ddclient/ddclient.pid

必要なモジュールのインストール

Perl モジュールの Data::Validate::IP がないって怒られたので、これもインストールしてください。
cpanm すらなかったらそれもインストールしましょう。 1

install Data::Validate::IP
$ sudo yum install perl-App-cpanminus
$ cpanm Data::Validate::IP

テスト実行

最後に SUCCESS と出ていたら成功です。お疲れさまでした。
サービス起動も忘れずにやっておきましょう。

test
$ sudo ddclient -daemon=0 -debug -verbose -noquiet
=== opt ====
opt{cache}                           : <undefined>
opt{cmd}                             : <undefined>
opt{cmd-skip}                        : <undefined>
opt{daemon}                          : 0
opt{debug}                           : 1
opt{exec}                            : <undefined>
opt{facility}                        : <undefined>
opt{file}                            : <undefined>
...((snip))...
SUCCESS:  your.domain.example.com: skipped: IP address was already set to xxx.xxx.xxx.xxx.
$ sudo systemctl start ddclient

  1. ddclient の初期インストールで JSON::Any がないって怒られたときは EPEL からインストールして誤魔化したけど Data::Validate::IP は EPEL になかったので泣く泣く入れました