打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
[實作] 動態網域伺服器 GnuDIP Dynamic DNS
本文轉自小弟的blog:
[實作] GnuDIP Dynamic DNS

  市面上有no-ip, dyndsn等 DDNS (Dynamic DNS),雖然是免費,但一用自己的domain就要收費了,如果已經有自己的DNS伺服器實在不划算,筆者找到這好好東東︰

http://gnudip2.sourceforge.net/


先看看GnuDIP的運作流程︰




  就是這麼簡單,當然先要架一台Bind9的DNS(Bind8都可以,只是筆者用的是Bind9),而且假設各位懂得架設Bind DNS,不懂的話可以先到http://linux.vbird.org上課,安裝GnuDIP Server有以下要求︰[separator]

代碼: [選擇]


1. Perl

2. Bind8/Bind9 (要有nsupdate 指令)

3. Sendmail/Exim/qmail/Postfix (的 sendmail 指令)

4. MySQL/PostgreSQL (用作儲存帳號,本筆記不用,改用file system)




另外,這是筆者的實作環境︰

1. CentOS 4.4
2. Bind9

  開始,我的GnuDIP Service是放在Bind那台機上一同跑的,程序如下︰

1. 先到http://gnudip2.sourceforge.net/下載gnudip-2.3.5.tar.gz。

2. 解壓到伺機器,把 gnudip 複製到 /usr/local/

3. 設定DNS

代碼: [選擇]


# cd /usr/local/gnudip/etc/
# rm -rf Kgnudip-key* (刪除預設的dns keys)

# dnssec-keygen -a hmac-md5 -b 128 -n HOST gnudip-key (制作dns keys)
Kgnudip-key.+157+xxxxx
# ls
Kgnudip-key.+157+xxxxx.key  Kgnudip-key.+157+xxxxx.private
# cat Kgnudip-key.+157+xxxxx.private
Private-key-format: v1.2
Algorithm: 157 (HMAC)
Key: [hash key]
# cat Kgnudip-key.+157+xxxxx.key
gnudip-key. IN KEY 513 3 157 [hash key]

(xxxxx是隨機的,總之能產生dns key就好了)




4. 修改 /usr/local/gnudip/etc/gnudip.conf,令GnuDIP可以成功更新DNS :

代碼: [選擇]


# BIND nsupdate command
nsupdate = /usr/bin/nsupdate -v
nsupdate = -k /usr/local/gnudip/etc/Kgnudip-key.+157+xxxxx.private (就是剛才產生的key file)



5. 到Bind的設定檔目錄,建立一個key file(/var/named/chroot/etc/gnudip.key)

代碼: [選擇]


key gnudip-key {

        algorithm hmac-md5;
        secret "[hash key]";  (剛才產生的key,抄過來就可以)
};



6. 修改 named.conf (/var/named/chroot/etc/named.conf), 筆者以"ddns.local"為例

代碼: [選擇]


// 加載Bind的dns key
include "/etc/gnudip.key";

zone "ddns.local" {
        type master;

        // 有關ddns.local的dns設定
        file "/var/named/ddns.local.hosts";


        allow-transfer {
                192.168.1.0/24;
                };

        // 給所有人query
        allow-query {
                any;
                };


        also-notify {
                192.168.1.200;
                192.168.1.201;
                };

        // 設定更新政策
        update-policy { grant gnudip-key subdomain ddns.local; };
        };



7. 修改 /var/named/chroot/var/named/ddns.local.hosts

代碼: [選擇]


$ORIGIN .
$TTL 86400      ; 1 day
ddns.local        IN SOA  ddns.local. ddns.local. (
                                22         ; serial
                                300        ; refresh (5 minutes)
                                150        ; retry (2 minutes 30 seconds)
                                604800     ; expire (1 week)
                                0          ; minimum (0 seconds)
                                )
                        NS      ddns.local.
                        A       192.168.1.1




8. 設定測試︰

代碼: [選擇]


# /etc/init.d/named reload (更新設定)
# /usr/bin/nsupdate -v -k /usr/local/gnudip/etc/Kgnudip-key.+157+xxxxx.private (用dns key執行nsupdate)
> update add test.ddns.local.  0  A  127.0.0.1 (加入 test.ddns.local. ,IP=127.0.0.1)
> send (傳送更新)
> (Ctrl-D 退出)

# ping test.ddns.local (如果回傳 127.0.0.1,就成功啦 ^_^)



9. 設定xinetd:

建立 /etc/xinetd.d/gnudip:
代碼: [選擇]

service gnudip
{
        flags       = REUSE
        socket_type = stream
        protocol    = tcp
        wait        = no
        user        = nobody
        server      = /usr/local/gnudip/sbin/gdipinet.pl
        bind        = 0.0.0.0
}



# /etc/init.d/xinetd restart

10. GnuDIP預設用MySQL儲存帳號,本人為了簡單用file system,所以要改symbolic links:

代碼: [選擇]

# cd /usr/local/gnudip/lib
# unlink dbusers.pm
# unlink gdipfrun.pm
# ln -s dbusers_flat.pm dbusers.pm
# ln -s gdipfrun_replacethread.pm gdipfrun.pm


11. 把/usr/local/gnudip/sbin加到 $PATH
代碼: [選擇]


# export PATH=$PATH:/usr/local/gnudip/sbin



12. 建立帳號︰

帳號︰helloword
密碼︰THIS_IS_PASSWORD
網域︰ddns.local
代碼: [選擇]


# gdipuseradd.pl -p THIS_IS_PASSWORD helloword ddns.local (建立帳號)

# chown -R nobody:nobody /usr/local/gnudip/run/database/users (把建立的帳號user, group變為nobody)



13. 用戶端設定、測試 (MS Windows)︰

用戶端IP設定︰192.168.1.2

下載 gnudip client standalone gnudip-2.3.5-gdipc-sa.exe,standalone包了需要的perl工具

代碼: [選擇]


 把解壓了的 gdipc 放到 C:\,再執行以下指令︰

C:\> cd \gdipc

C:\gdipc>config.bat

Using Update Configuration Mode
Configuration file name: C:/gdipc/gdipc.conf.txt
Username: helloworld
Domain: ddns.local
Connect by direct TCP (d) or web server (w) [d]:
GnuDIP Server - host[:port]: ddns.local
Password: THIS_IS_PASSWORD
Cache File [C:/gdipc/gdipc.cache.helloworld.ddns.local.txt]:
Minimum Seconds Between Updates [0]:
Maximum Seconds Between Updates [2073600]:


C:\gdipc>gdipc.bat

====  gdipc.bat running:  Mon Feb 19 16:45:04 2007  ====
Configuration file name: C:/gdipc/gdipc.conf.txt
Cache file name: C:/gdipc/gdipc.cache.helloworld.ddns.local.txt
Attempting update at ddns.local...
Update to address 192.168.1.2 from x.x.x.x successful for helloworld.ddns.local.



(註︰如果用戶端在NAT之內,又希望回傳Gateway的IP),可以用以下語法︰

代碼: [選擇]


C:\gdipc>gdipc.bat -g [sendport]:[recvport]

[sendport], [recvport]都是UDP ports,用作回傳Gateway IP使用。



最後試試DNS是否成功更新︰

代碼: [選擇]


c:\> ping helloworld.ddns.local

回傳自己IP (192.168.1.2) 的話就成功了






參考閱讀︰
GnuDIP Release 2.3.5 - INSTALL File
GnuDIP User Maintenance Commands
GnuDIP Client-Server Update Protocolhttp://
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Win10和office2016密钥无效怎么卸载更换
『脚本』使用修改版CloudFlare脚本实现DDNS,含Lightsail被墙自动换ip
windows8.1激活命令(自己找key)
Windows10最新最全激活密钥和激活方法分享
SoftEther  之DDNS
预装家庭普通版WIN7升级到旗舰版的KEY
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服