天天看點

【DDNS更新】--公雲的DDNS自動更新

【摘要】-- 由于各種原因,最終使用了公雲(www.pubyun.com/)的免費DDNS,但是我們的外網IP是一個變化的,經常IP就發生了變化,DDNS也就無法通路了。

【解決方案】

    使用官方提供的用戶端去更新:http://www.pubyun.com/products/dyndns/download/

    其中提到了Linux下面更新IP的方式:

[root@Dragonwake ~]# lynx -mime_header -auth=使用者名:密碼 "http://members.3322.net/dyndns/update?system=dyndns&hostname=域名"     HTTP/1.1 200 OK     Server: nginx     Date: Fri, 18 May 2018 02:29:59 GMT     Content-Type: text/plain; charset=utf-8     Connection: close     Vary: Cookie     good 59.174.250.25           

    還是很麻煩,IP變化之後需要手動輸入這條指令,這個時候想到了Linux下面的Crontab + Shell實作自動更新IP

    編寫/root/update_ddns.sh腳本

#! /bin/bash     # 更新DDNS的IP位址     lynx -mime_header -auth=使用者名:密碼 "http://members.3322.net/dyndns/update?system=dyndns&hostname=域名" >> /var/log/update_ddns.log           

    寫完之後,别忘記了給腳本添加可執行權限

[root@Dragonwake ~]# chmod +x /root/update_ddns.sh           

    添加Crontab執行計劃

[root@Dragonwake ~]# crontab -e           
*/30 * * * * /root/update_ddns.sh           

    檢視日志

[root@Dragonwake ~]# tail -f /var/log/update_ddns.log      nochg 111.175.50.154     HTTP/1.1 200 OK     Server: nginx     Date: Thu, 17 May 2018 13:36:52 GMT     Content-Type: text/plain; charset=utf-8     Connection: close     Vary: Cookie     good 59.174.250.25           

繼續閱讀