Openwrt - ddns

 

方案

  • ddns-scripts
  • inadyn

 

方法1: ddns-scripts

 

安裝:

opkg install ddns-scripts    <--- 此 script 是利用 wget 去 update DDNS

設定檔:

/etc/config/ddns

config service "myddns"
        option enabled          "1"                 <--- 由於可以登記多個 ddns, 所以每一組都有個別的 ebabled
        option interface        "wan"               <--- 對應  ip_source 是 network 時用

        option service_name     "dyndns.org"        <--- 對應 /usr/lib/ddns/services 內的值
                                                         如果在 list 沒有對應時, 那就要用 update_url 去設定更新DNS的 URL

        option domain           "youdomain.dyndns.org"  <--- 認證資料
        option username         "myusername"
        option password         "mypassword"

        option force_interval   "24"                    <--- 更新時間
        option force_unit       "hours"
        option check_interval   "10"
        option check_unit       "minutes"
        option retry_interval   "60"
        option retry_unit       "seconds"

        option ip_source        "web"                          <--- 獲得外部 IP 的方式, 一般而言, web 是最好的 
        option ip_url           "http://checkip.dyndns.com/"   <--- first valid ip address listed on that page

餘下設定:

        #option ip_source       "network"
        #option ip_network      "wan"

        #option ip_source       "interface"
        #option ip_interface    "eth0.1"

        #option ip_source       "script"
        #option ip_script       "path to your scrip"

        #option update_url      "http://[USERNAME]:[PASSWORD]@members.dyndns.org/nic/update?hostname=[DOMAIN]&myip=[IP]"

 

/usr/lib/ddns/services 內容:

(dyndns protocol compatible services)

"dyndns.org"  "http://[USERNAME]:[PASSWORD]@members.dyndns.org/nic/update?hostname=[DOMAIN]&myip=[IP]"

 

更新原理:

/etc/hotplug.d/iface/25-ddns

#!/bin/sh

. /usr/lib/ddns/dynamic_dns_functions.sh

if [ "$ACTION" = "ifup" ]; then
        start_daemon_for_all_ddns_sections "$INTERFACE"
fi

 

Debug:

# 用 /etc/config/ddns 內的 myddns 更新

/usr/lib/ddns/dynamic_dns_updater.sh myddns

Output:

update_url=http://[USERNAME]:[PASSWORD]@members.dyndns.org/nic/update?hostname=[DOMAIN]&myip=[IP]
force seconds = 43200
check seconds = 300
time_since_update = 24 hours
Running IP check...
current system ip =
registered domain ip =
update necessary, performing update ...
updating with url=""
Connecting to members.dyndns.org (204.13.248.111:80)
-                    100% |*************************|    19   0:00:00 ETA
Update Output:
good 203.xxx.31.236

update complete, time is: Wed Aug 1 19:40:27 HKT 2012

 


方法2: inadyn

 

Configure File:

/tmp/ddns/

  • ddns.log          
  • inadyn.conf       
  • inadyn_ip.cache   
  • inadyn_time.cache

Backgroup running

inadyn -u xxx -p xxx --input_file /tmp/ddns/inadyn.conf

INADYN: Started 'INADYN version 1.96.2' - dynamic DNS updater.
I:INADYN: IP address for alias 'datahunter.org' needs update to '123.202.144.65'
I:INADYN: Alias 'tim.dnslink.hk' to IP '123.202.144.65' updated successful.

 

 

Creative Commons license icon Creative Commons license icon