Zoneedit.comで動的IPアドレスによる独自ドメイン運用 (ddclient利用)

先日ドメイン(kuniharumaki.com)を取得した。
今利用中のkuniharumaki.comドメインから移行するにあたって、まずはDynamic DNSとして利用できるDNSサービスを選定。
SPF設定のためにTXTレコードが編集できるところで、かつ無料のところを探してみたところ、有名そうなところではZoneEdit.comが良さそうだったので、とりあえずここに。

IPアドレスの通知は特定ページにアクセスすれば出来るようだが、Ubuntuにはddclientという便利なパッケージがあるので、それを使うことにする。
以下は覚え書き。

使うパッケージはこれ

# aptitude show ddclient
Package: ddclient
New: yes
State: not installed
Version: 3.8.0-9ubuntu2
Priority: extra
Section: universe/net
Maintainer: Ubuntu Developers
Uncompressed Size: 369k
Depends: perl5, debconf (>= 0.5) | debconf-2.0, lsb-base (>= 3.1), initscripts (>= 2.86)
Recommends: libio-socket-ssl-perl
Provides: dyndns-client
Description: address updating utility for dynamic DNS services
This package provides a client to update dynamic IP addresses with several dynamic DNS service providers, such as DynDNS.com.

This makes it possible to use a fixed hostname (such as myhost.dyndns.org) to access a machine with a dynamic IP address.

This client supports both dynamic and (near) static services, as well as MX record and alternative name management. It caches the address, and only attempts the update when it has changed.
Homepage: http://ddclient.sf.net

さくっとインストール。いくつかperlのモジュールが必要となるみたいなので一緒に入れる。
途中でいくつか質問に答えるとインストール完了。(後で編集できるので適当でOK)

# aptitude install ddclient
The following NEW packages will be installed:
ddclient libio-socket-ssl-perl{a} libnet-libidn-perl{a} libnet-ssleay-perl{a}
0 packages upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 361kB of archives. After unpacking 1675kB will be used.
Do you want to continue? [Y/n/?]
Writing extended state information… Done
Get:1 http://jp.archive.ubuntu.com/ubuntu/ lucid/universe libnet-ssleay-perl 1.35-2ubuntu1 [209kB]
Get:2 http://jp.archive.ubuntu.com/ubuntu/ lucid/universe libio-socket-ssl-perl 1.31-1 [58.3kB]
Get:3 http://jp.archive.ubuntu.com/ubuntu/ lucid/universe libnet-libidn-perl 0.12.ds-1 [23.9kB]
Get:4 http://jp.archive.ubuntu.com/ubuntu/ lucid/universe ddclient 3.8.0-9ubuntu2 [70.3kB]
Fetched 361kB in 0s (364kB/s)
Setting up libnet-ssleay-perl (1.35-2ubuntu1) …
Setting up libio-socket-ssl-perl (1.31-1) …
Setting up libnet-libidn-perl (0.12.ds-1) …
Setting up ddclient (3.8.0-9ubuntu2) …

Reading package lists… Done
Building dependency tree
Reading state information… Done
Reading extended state information
Initializing package states… Done
Writing extended state information… Done

設定変更その1 /etc/default/ddclient
daemon_intervalをデフォルトの300から900に変更。そこまで重要なサーバでも無いから、15分ごとくらいで十分。

# grep -v -e “^$” -e “^#” /etc/default/ddclient
run_ipup=”false”
run_daemon=”true”
daemon_interval=”900″

設定変更その2 /etc/ddclient.conf

# grep -v -e “^$” -e “^#” /etc/ddclient.conf
mail=root
mail-failure=root
use=web
protocol=zoneedit1, \
server=dynamic.zoneedit.com, \
login=[ユーザID], \
password=[パスワード] \
kuniharumaki.com,mail.kuniharumaki.com,www.kuniharumaki.com
protocol=noip, \
login=[ユーザID], \
password=[パスワード] \
kuniharumaki.com

こんな感じで設定完了。
ちなみにuse=webのところは、Routers – ddclientのページを確認して、最適なメソッドを使うのがよいだろう。
webを指定した場合、ソースを見てみると、http://checkip.dyndns.org/ もしくは http://ipdetect.dnspark.com/ にアクセスをして、IPアドレスを取得するので、若干ではあるがこれらのサーバに負荷をかけるので、別の方法で通知すべきIPアドレスが得られる場合は、そちらを選択したい。
うちのサーバはプライベートIPアドレスで運用していて、かつルータも非対応の物だったので、残念ながらwebを利用した。

# service ddclient restart
で設定を反映してから、syslogを確認して、

ddclient[4752]: SUCCESS: updating kuniharumaki.com: IP address set to xxx.xxx.xxx.xxx (201: No records need updating.)
ddclient[4752]: SUCCESS: updating mail.kuniharumaki.com: IP address set to xxx.xxx.xxx.xxx (201: No records need updating.)
ddclient[4752]: SUCCESS: updating www.kuniharumaki.com: IP address set to xxx.xxx.xxx.xxx (201: No records need updating.)

みたいなログが残っていれば完了。

ちなみに、curlとかでも一応更新は可能。

# curl –retry 5 –retry-delay 30 -m 60 -u [ID]:[password] -k ‘https://dynamic.zoneedit.com/auth/dynamic.html?host=kuniharumaki.com&host=www.kuniharumaki.com&host=mail.kuniharumaki.com’
<SUCCESS CODE=”201″ TEXT=”No records need updating.” ZONE=”kuniharumaki.com” HOST=”kuniharumaki.com”><SUCCESS CODE=”201″ TEXT=”No records need updating.” ZONE=”kuniharumaki.com” HOST=”kuniharumaki.com”><SUCCESS CODE=”201″ TEXT=”No records need updating.” ZONE=”kuniharumaki.com” HOST=”mail.kuniharumaki.com”>
<SUCCESS CODE=”201″ TEXT=”No records need updating.” ZONE=”kuniharumaki.com” HOST=”kuniharumaki.com”><SUCCESS CODE=”201″ TEXT=”No records need updating.” ZONE=”kuniharumaki.com” HOST=”kuniharumaki.com”><SUCCESS CODE=”201″ TEXT=”No records need updating.” ZONE=”kuniharumaki.com” HOST=”mail.kuniharumaki.com”>

こんな感じ。レスポンスはXMLで返ってくる。

なぜかhttpsページの方がレスポンスが良かったので、期限切れ証明書のエラーを無視(-kオプション)して実行してる。

コメント

by Cocoon 本日: 0 週: 0 月: 0 全体: 5
タイトルとURLをコピーしました