まずはお約束の設定変更。
$ sudo /usr/sbin/groupmod -n owner yanoで、グループ名とデフォルトエディタを変更。
$ sudo update-alternatives --config editor
$ sudo visudosudoでいちいちパスワードを打たなくていいようvisudoでNOPASSWDオプションを付与しておく。
%admin ALL=(ALL) NOPASSWD: ALL
$ sudo vi /etc/ssh/sshd_configで、sshのポート番号を変更し、パスワード認証とrootログインを禁止。
$ sudo /etc/init.d/ssh restart
続いてaptをアップデートし、ntpやbuild-essentialを導入し、ntpサーバをntp.jst.mfeed.ad.jpに変更。
$ sudo apt-get update
$ sudo apt-get install ntp build-essential
$ sudo vi /etc/ntp.conf
$ sudo /etc/init.d/ntp restart
それからnsdを導入。パッケージとしてはnsd3とnsdがあるが、積極的に旧版をチョイスするだけの根拠は持ち合わせて無いので、素直にnsd3を導入。
$ sudo apt-get install nsd3と、ひと通りのインストールは出来ているみたいだが~/etc/nsd3/nsd.confが無いという事で起動エラーが出る。ていうか、何も設定してないのに起動しちゃダメでしょう、というわけで/var/lib/dpkg/info/nsd3.postinstのサービス起動処理をコメントアウト
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
nsd3
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 842kB of archives.
After this operation, 1,622kB of additional disk space will be used.
Get:1 http://jp.archive.ubuntu.com/ubuntu/ lucid/universe nsd3 3.2.4-1 [842kB]
Fetched 842kB in 0s (1,037kB/s)
Selecting previously deselected package nsd3.
(Reading database ... 42388 files and directories currently installed.)
Unpacking nsd3 (from .../archives/nsd3_3.2.4-1_i386.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Setting up nsd3 (3.2.4-1) ...
dpkg-statoverrides: warning: --update given but /etc/nsd3/nsd.conf does not exist
Could not open /etc/nsd3/nsd.conf: No such file or directory
Could not open /etc/nsd3/nsd.conf: No such file or directory
* Building nsd3 zones...
Could not open /etc/nsd3/nsd.conf: No such file or directory
invoke-rc.d: initscript nsd3, action "start" failed.
dpkg: error processing nsd3 (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
nsd3
E: Sub-process /usr/bin/dpkg returned an error code (1)
$ sudo ls -la /etc/nsd3/
total 16
drwxr-x--- 2 nsd nsd 4096 2011-04-21 15:44 .
drwxr-xr-x 77 root root 4096 2011-04-21 15:44 ..
-rw-r--r-- 1 root root 4406 2010-02-09 00:35 nsd.conf.sample
#!/bin/sh -eして
set_perms() {
if ! dpkg-statoverride --list "$4" >/dev/null; then
dpkg-statoverride --update --add "$@"
fi
}
if test "$1" = "configure"; then
if ! getent passwd nsd > /dev/null; then
adduser --quiet --system --group --no-create-home nsd
fi
set_perms nsd nsd 0755 /var/lib/nsd3
set_perms nsd nsd 0640 /etc/nsd3/nsd.conf
set_perms nsd nsd 0750 /etc/nsd3
fi
# Automatically added by dh_installinit
if [ -x "/etc/init.d/nsd3" ]; then
update-rc.d nsd3 defaults >/dev/null
# if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
# invoke-rc.d nsd3 start || exit $?
# else
# /etc/init.d/nsd3 start || exit $?
# fi
fi
# End automatically added section
exit 0
$ sudo dpkg --configure -aで再適用しておくとOKだ。
さて肝心の設定は~/etc/nsd3/nsd.confと~/etc/nsd3/xn--48jd5f0d.jp.zoneの設定ファイル編集後、nsd-checkconfで書式を確認し、nsdc rebuildでdbをアップデートした後、nsdc startする流れ。
$ mkdir ~yano/etcという結果になれば、ひとまず設定はOK。
$ sudo mv /etc/nsd3 ~yano/etc
$ sudo ln -s ~yano/etc/nsd3 /etc
$ chmod 755 ~yano/etc/nsd3
$ sudo chown -R yano:owner ~yano/etc/nsd3 /etc
$ cd ~yano/etc/nsd3
$ cp -p nsd.conf.sample nsd.conf
$ vi ~/etc/nsd3/nsd.conf
$ vi ~/etc/nsd3/xn--48jd5f0d.jp.zone
$ nsd-checkconf /etc/nsd3/nsd.conf
$ sudo nsdc rebuild
$ sudo nsdc start
$ nslookup xn--48jd5f0d.jp localhost
Server: localhost
Address: 127.0.0.1#53
Name: xn--48jd5f0d.jp
Address: 49.212.xx.yyy
【参照】
●VPS(仮想専用サーバ)のさくらインターネット http://vps.sakura.ad.jp/