HomeNAS IP变化规律

新浪微博 QQ空间

成都电信分配给个人的家用宽带IP地址定期更新,本来是用来快速发现变化后的IP地址的一个任务,解决IP地址变化后需要15分钟才能登录的问题,结果让发现了IP地址变化的规律。每隔6天,在每天中午11点20后的一个小时内更新IP地址。不知道是只针对特定账号的任务还是所有人同一时刻变更。

IP Changed

image

这里也分享一下监控脚本源码:

#!/bin/bash

getip() {
echo $(curl https://ip.tool.lu 2>;/dev/null|grep IP|awk '{print $2}'|tr -d '^M')
}

lastip=$(getip)
while :
do
sleep 5
ip=$(getip)
if [ ! -z "$ip" -a "$ip" != "${lastip}" ]
then
echo $(date) >;> result.txt
echo "ip changed from ${lastip} to ${ip}" >;> result.txt
curl -s --user 'api:XXXXXXXXXXXXXXXXX' https://api.mailgun.net/v3/codefine.site/messages -F from='Shentar admin@xxx.com' -F to=youremail@address -F subject='Home NAS IP Changed!' -F text="ip changed form ${lastip} to ${ip}"
lastip=${ip}
fi
done

具体的账号秘钥和邮箱地址均已隐去。使用ip.tool.lu识别本机的外网IP,然后监控指定间隔内两次IP地址的变化。如果发生变化,则使用MailGun服务发送邮件到指定邮箱。

新浪微博 QQ空间

| 1 分2 分3 分4 分5 分 (5.00- 1票) Loading ... Loading ... | 这篇文章归档在:WEB网络, 实用脚本, 移动互联 | 标签: , , . | 永久链接:链接 | 评论(0) |

评论

邮箱地址不会被泄露, 标记为 * 的项目必填。

8 - 2 = *



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <img alt="" src="" class=""> <pre class=""> <q cite=""> <s> <strike> <strong>

返回顶部