作者:hzl88688 | 更新时间:2016-03-06 | 浏览量:2217
#!/bin/ash
shPath=$(cd `dirname $0`; pwd)
ip_regex="[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}"
myip=$(echo $( wget -O - http://ddns.nat123.com 2>/dev/null) | grep -o "$ip_regex")
myOldIp=$(cat ${shPath}/oldIp.txt)
if [ $3 ]
then
param3=$3
else
param3=80
fi
if [ ${myip} = ${myOldIp} ]
then
exit
else
wget -o ${shPath}/status.txt http://www.bigiot.net/Dns/updateDns?id=$1\&ip=${myip}\&pw=$2\&pt=${param3}
status=$(cat ${shPath}/status.txt)
echo $myip > ${shPath}/oldIp.txt
echo ${status}
fi
if [ ${myip} = ${myOldIp} ]
if [ ${myip} == ${myOldIp} ]
if [ ${myip} != ${myOldIp} ]
if [ ${myip} ~= ${myOldIp} ]
local http = require("socket.http") --http
------------此处需修改-------------
DNSID="1" --DNS网关ID
DNSPWD="123456787" --DNS网关密码
DNSPort="80" --DNS网关端口
while true do
if ((os.time() - lastUpdateTime) > 20) then
local address=luci.util.ubus("network.interface.wan","status") or {}
myipv4=address["ipv4-address"][1]["address"]
if(myipv4 ~= myOldIp) then
local htpres=http.request("http://www.bigiot.net/Dns/updateDns?id="..DNSID.."\&ip="..myipv4.."\&pw="..DNSPWD.."\&pt="..DNSPort)
print(htpres)
myOldIp=myipv4
end
end