發新話題
打印

[轉貼]MyDNS 安裝筆記 for Debian Linux

[轉貼]MyDNS 安裝筆記 for Debian Linux

http://blog.roga.tw/2009/08/25/2292

前置作業:

必須先有一個資料庫(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

01#! /bin/sh
02# mydns         Start the MyDNS server
03# Author:       Falko Timme <ft@falkotimme.com>.
04set -e
05 
06PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
07NAME=mydns
08DAEMON=/usr/local/sbin/$NAME
09DESC="MyDNS Server"
10 
11SCRIPTNAME=/etc/init.d/$NAME
12 
13# Gracefully exit if the package has been removed.
14test -x $DAEMON || exit 0
15 
16case "$1" in
17  start)
18        echo -n "Starting $DESC: $NAME"
19        $DAEMON --background
20        echo "."
21        ;;
22  stop)
23        echo "Stopping $DESC: $NAME."
24        kill -9 `pidof $NAME` &> /dev/null
25        ;;
26  restart)
27        echo "Restarting $DESC: $NAME."
28        $0 stop && sleep 1
29        $0 start
30        ;;
31  *)
32        echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
33        exit 1
34        ;;
35esac
36exit 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


TOP

發新話題