目次

ddclientでDynDNSを自動更新する

FreeBSD 6.1-RELEASEでddclientでダイナミックDNSサービスの1つ、DynDNSのDNS情報を自動更新する方法のメモ。

ddclientのインストール

portsからddclientをインストールする。

cd /usr/ports/dns/ddclient
make install; clean

ddclientの設定

/usr/local/etc/ddclient.conf.sampleをコピーしたファイルに設定を書き込む。

# cd /usr/local/etc
# cp ddclient.conf.sample ddclient.conf
# ee ddclient.conf

#use=ip,                     ip=127.0.0.1       # via static IP's
#use=if,                     if=eth0            # via interfaces
use=web                                         # via web
(Webサイト経由でIPアドレスを取得する)

login=(ユーザー名)                              # default login
password=(パスワード)                           # default password
#mx=mx.for.your.host                            # default MX
#backupmx=yes|no                                # host is primary MX?
#wildcard=yes|no                                # add wildcard CNAME?

##
## dyndns.org dynamic addresses
##
## (supports variables: wildcard,mx,backupmx)
 server=members.dyndns.org,             \
 protocol=dyndns2                       \
 (取得したDynDNSホスト名)

rc.confの設定

ddclientをデーモンとして起動させるために、/etc/rc.confに以下の一文を付け加える。

ddclient_enable="YES"

動作確認

以下のコマンドを実行し、正しく動作するか確認する。

# ddclient -daemon=0 -debug -verbose -noquiet
(中略)
=== cache ====
DEBUG:    proxy  = 
DEBUG:    url    = http://checkip.dyndns.org/
DEBUG:    server = checkip.dyndns.org
DEBUG:    opt(fw = 
Use of uninitialized value in concatenation (.) or string at /usr/local/sbin/ddclient line 1646.
DEBUG:    glo fw = 
CONNECT:  checkip.dyndns.org
CONNECTED:  using HTTP
SENDING:  GET / HTTP/1.0
SENDING:   Host: checkip.dyndns.org
SENDING:   User-Agent: ddclient/3.7.0
SENDING:   Connection: close
SENDING:   
RECEIVE:  HTTP/1.1 200 OK
RECEIVE:  Content-Type: text/html
RECEIVE:  Server: DynDNS-CheckIP/0.2
RECEIVE:  Connection: close
RECEIVE:  Cache-Control: no-cache
RECEIVE:  Pragma: no-cache
RECEIVE:  Content-Length: 105
RECEIVE:  
RECEIVE:  <html><head><title>Current IP Check</title></head><body>Current IP Address: XXX.XXX.XXX.XXX</body></html>
DEBUG:    get_ip: using web, http://checkip.dyndns.org/ reports XXX.XXX.XXX.XXX
INFO:     forcing updating your-host.dyndns.org because no cached entry exists.
DEBUG:    
DEBUG:     nic_dyndns2_update -------------------
INFO:     setting IP address to XXX.XXX.XXX.XXX for your-host.dyndns.org
UPDATE:   updating your-host.dyndns.org
DEBUG:    proxy  = 
DEBUG:    url    = http://members.dyndns.org/nic/update?system=dyndns&hostname=your-host.dyndns.org&myip=XXX.XXX.XXXX.XXX
DEBUG:    server = members.dyndns.org
DEBUG:    opt(fw = 
Use of uninitialized value in concatenation (.) or string at /usr/local/sbin/ddclient line 1646.
DEBUG:    glo fw = 
CONNECT:  members.dyndns.org
CONNECTED:  using SSL
SENDING:  GET /nic/update?system=dyndns&hostname=your-host.dyndns.org&myip=XXX.XXX.XXX.XXX HTTP/1.0
SENDING:   Host: members.dyndns.org
SENDING:   Authorization: Basic YYYYYYYYYYYYYYYY
SENDING:   User-Agent: ddclient/3.7.0
SENDING:   Connection: close
SENDING:   
RECEIVE:  HTTP/1.1 200 OK
RECEIVE:  Date: Sun, 10 Sep 2006 01:28:56 GMT
RECEIVE:  Server: Apache/1.3.33 (Unix) mod_perl/1.29
RECEIVE:  Content-Type: text/plain; charset=ISO-8859-1
RECEIVE:  Connection: close
RECEIVE:  
RECEIVE:  nochg XXX.XXX.XXX.XXX
WARNING:  updating your-host.dyndns.org: nochg: No update required; unnecessary attempts to change to the current address are considered abusive

このログでは「IPアドレスが変わってないから、登録情報を変更する必要はないよ」と出ているので、恐らく上手く動作していると思われる。