2009
08.25

MyDNS 安裝筆記 for Debian Linux

前置作業:

必須先有一個資料庫(MySQL, PostgreSQL),並且正確設定帳號密碼。並且安裝 MySQL CLient Library (套件名稱類似:libmysqlclient16,搜尋方式 apt-cache search libmysqlclient )

安裝步驟:

cd /tmp
wget http://mydns.bboy.net/download/mydns-1.1.0.tar.gz
tar xvfz mydns-1.1.0.tar.gz

下載原始檔,存到 /tmp 之後解壓縮。

cd mydns-1.1.0/
./configure
make
make install

切換到目錄,並且編譯,預設使用 MySQL ,如果 ./configure –without-mysql 代表使用 PostgreSQL 。編譯完成後,會有提示如下:

  ###  mydns version 1.1.0 installed!
  ###
  ###  See the file QUICKSTART if you are in a hurry.
  ###  Otherwise, consult the manual (in doc/).
  ###
  ###  The MyDNS server program was installed as
  ###  /usr/local/sbin/mydns
  ###
  ###  Your configuration file should be installed as
  ###  /etc/mydns.conf
  ###  (You can auto-create it with "make conf")
  ###

編輯 /etc/mydns.conf ,裡面可以修改資料庫的連線設定,以及執行 MyDNS 的使用者和群組(可設定為 nobody/nogroup)。然後利用 mydns 自己的指令新增資料表:

mydns --create-tables | mysql -u root -p dbname

dbname 是您的資料庫的名稱,這個指令會建立 soa 和 rr 兩個資料表。
接著在資料庫中修改欄位屬性:

ALTER TABLE soa ADD COLUMN active ENUM('Y','N') NOT NULL;
ALTER TABLE soa ADD INDEX (active);
ALTER TABLE soa ADD COLUMN xfer CHAR(255) NOT NULL;

然後在 /etc/init.d 裡面建立一個 shell script

#! /bin/sh
# mydns         Start the MyDNS server
# Author:       Falko Timme <ft@falkotimme.com>.
set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=mydns
DAEMON=/usr/local/sbin/$NAME
DESC="MyDNS Server"

SCRIPTNAME=/etc/init.d/$NAME

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

case "$1" in
  start)
        echo -n "Starting $DESC: $NAME"
        $DAEMON --background
        echo "."
        ;;
  stop)
        echo "Stopping $DESC: $NAME."
        kill -9 `pidof $NAME` &> /dev/null
        ;;
  restart)
        echo "Restarting $DESC: $NAME."
        $0 stop && sleep 1
        $0 start
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
        exit 1
        ;;
esac
exit 0

執行 /etc/init.d/mydns start 看看能不能跑起來,沒有問題的話,讓服務開機自動啟動:

update-rc.d mydns defaults 21 22

接著複製系統裡面內建的管理介面到 www 目錄下:

cp /tmp/mydns-1.0.0/contrib/admin.php /var/www

接著修改 admin.php ,修改資料庫連線設定。如果把 $auto_update_serial 和 $auto_update_ptr 設定為 1 ,系統會在修改資料的時候,自動增加數值。

參考資料:Running A MySQL-Based DNS Server: MyDNS

No Comment.

Add Your Comment
:D :-) :( :o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>