Giter VIP home page Giter VIP logo

dnspod-shell's Introduction

ArDNSPod

基于 DNSPod 用户 API 实现的纯 Shell 动态域名客户端。

  • IPv4 优先适配网卡地址,无法获得合法外网地址则从第三方接口获取地址,依然失败则使用DNSPod接口自动更新
  • IPv6 优先适配网卡地址,无法获得合法外网地址则从第三方接口获取地址,依然失败则退出
  • IP地址接口项目源码参见 https://github.com/rehiy/docker-geoip-api

官方DDNS接口已支持设置IPv6,如有兼容问题请使用v6.1分支版本

使用方法

  • 编辑ddnspod.sh,分别修改/your_real_path/ardnspodarTokenarDdnsCheck为真实信息

  • 运行ddnspod.sh,开启循环更新任务;建议将此脚本支持添加到计划任务;

  • 成功运行后,结果如下所示:

=== Check test.rehi.org ===
Fetching Host Ip
> Host Ip: Auto
> Record Type: A
Fetching RecordId
> Record Id: 998534425
Updating Record value
> arDdnsUpdate - 1.2.3.4

小提示

  • 如需单文件运行,参考ddnspod.sh中的配置项,添加到ardnspod底部,直接运行ardnspod即可
echo "arToken=12345,7676f344eaeaea9074c123451234512d" >> ./ardnspod
echo "arDdnsCheck test.org subdomain" >> ./ardnspod

最近更新

2023/8/5

  • 根据记录Id缓存本地IP

2023/7/22

  • Bug fix: 当需要替换根域名时, 如果传入 @ (如 @.domain.xx), 会错误得到 *.domain.xx 的结果 (A记录设置了*的话), 导致更新失败. 修改后在传入 @ 作为子域名时, 直接请求根域名的结果

2023/5/24

  • 恢复支持变更检测

2022/11/24

  • 支持指定网卡
  • 增加 arRequest 方法,实现 curl/wget 封装

2022/03/11

  • 改用ddns接口更新数据
  • ipv4 先从本机获取,若没有合法地址,则使用dnspod接口填充IP
  • ipv6 本机获取难度太大,且错误率高,改为直接从外部接口获取地址

2021/11/25

  • 优先选择剩余时间最长的ipv6地址 @kaedeair

2021/3/3

  • 强化获取IP结果检测
  • 优化部分判断逻辑
  • 优化消息输出

2021/2/8

  • 添加 IPv6 支持
  • 优化流程,减少 API 调用次数
  • 完善出错提示

2020/8/5

  • 修复 get the wrong recordID @C-Y-X

2020/1/1

  • 适配新版 API(2019-11-26)
  • wget不存在时,尝试使用curl提交
  • 由于readlink不可靠,更改为手动设置路径
  • 当无法从本地网卡获得外网 ip 时,尝试从外部 api 获取

2015/2/24

  • 增加 token 鉴权方式 (by wbchn)

2015/7/7

  • 使用 D+服务获取域名解析

2016/2/25

  • 增加配置文件,分离脚本与配置,适配内网。
  • 加入 Mac 支持
  • sed 脚本 POSIX 化,可跨平台

2016/3/23

  • 进一步 POSIX 化,支持 Mac 和大部分 Linux 发行版
  • 更改配置文件格式

2015/7/23

  • 代码托管到 github

2013/03/28

  • 稳定版发布,同时被收录到官方插件列表

2011/07/03

  • 小范围测试版发布

共同维护者

请参阅 https://github.com/rehiy/dnspod-shell/graphs/contributors

dnspod-shell's People

Contributors

c-y-x avatar dotin13 avatar duanego avatar duzhor avatar jqjiang819 avatar ljzd-pro avatar proffan avatar rehiy avatar shimada666 avatar vigilans avatar wbchn avatar wjfjfm avatar wysaid avatar wzhy90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dnspod-shell's Issues

OPENWRT 不能使用的解决办法

dnspodapi接口有改变,导致提取Domain id 失败
修改这句话
domainID=$(echo $domainID | sed 's/.{"id":"([0-9])"./\1/')

domainID=$(echo $domainID | sed 's/.
,"id":"([0-9])"./\1/')
就可完美解决。

Why not use $PWD instead of "rreadlink"?

I saw you use a script name "rreadlink" to get the current path of ddnspod.sh.
But why not use $PWD instead of this? $PWD is built in the bash so both Linux and Mac are supported it.

在crontab中无法更新

测试sh脚本已经没有问题了,然后加入到crontab中,无法更新。在sh脚本中加入测试代码,发现脚本也运行了,就是无法更新地址。

建议在域名更新参数增加record_id,用于更新同一subdomain不同的解析记录

dnspod.cn如果要对同一个子域名解析多个A记录,或者AAAA记录,服务端就要将子域名配置多条解析记录,API更新参数中只有子域名subdomain的话,只能更新服务端该子域名的首条解析记录,无法对首条后的记录进行更新。

举个例子,在服务端配置两条主机记录test,第一条为A记录,第二条为AAAA记录,API提交记录更新只带上subdomain=test的话,只能更新服务器的A记录,无法更新第二条AAAA记录。如果API带上record_id参数,API提交record_id="第二条记录的ID”,就可以指定更新第二条AAAA记录。

这样运行两条脚本,就能实现IPV4/IPV6双栈动态解析,也可以一个域名记录指定多个IPV4地址,实现域名负载均衡(DNSPOD支持IPV4的负载均衡)

更新不了,找不到问题求助。

【DNSPod动态域名】: 目前 IP: 222...*
【DNSPod动态域名】: 上次 IP: ...
【DNSPod动态域名】: Record line invalid
【DNSPod动态域名】: 更新动态DNS记录失败!请检查您的网络。提交的IP: 更新记录信息 recordID:

近期准备重写一下这个脚本

看到很多人依旧在使用这个脚本,但是这个脚本已经历时3年未更新。其中更是使用了 wget 的ssl模块,不知道大家认为是否有必要更改为 curl ?

已经联网却无法更新Update Failed! Please check your network.

Base on LEDE/OpenWrt (18.12, r4592, 2018-12-13-git-a1945fb)
Linux
Updating Domain: myDomain
hostIP: *.210.157.95 *.210.157.4 *.210.157.124
lastIP: *.210.157.124
Update Failed! Please check your network.
多拨用户,不知道有没有影响。
麻烦指导一下,谢谢!

判断语法问题

如题:

  • 197行
if [ "$recordIp" == "$4" ] && [ "$recordCd" == "1" ]; then

改成

if [ "$recordIp" = "$4" ] && [ "$recordCd" = "1" ]; then
  • 223行
if [ "$3" == "6" ]; then

修改

 if [ "$3" = "6" ]; then
  • 225行
if [ "$lastIp" == "$hostIp" ]; then

改成

if [ "$lastIp" = "$hostIp" ]; then

变量名 错误。。。

root@cubieboard4:/home/linaro/progranm/ArDNSPod# ./ddnspod.sh 
Linux
./ddnspod.sh: 160: local: 192.168.10.116: bad variable name

大哥 最新版 本变量名有问题
我的发型版 如下

root@cubieboard4:/home/linaro/progranm/ArDNSPod# cat /etc/issue
Linaro 14.04 \n \l

root@cubieboard4:/home/linaro/progranm/ArDNSPod# uname -a
Linux cubieboard4 3.4.39 #65 SMP PREEMPT Thu Apr 30 17:25:26 CST 2015 armv7l armv7l armv7l GNU/Linux

脚本在openwrt上运行错误

root@OpenWrt:~/ArDNSPod# ./ddnspod.sh
Updating Domain: x.yz.com
hostIP: 49.171.63.47
lastIP: 49.171.63.147
wget: bad address 'completed'
wget: bad address 'completed'
Update Failed! Please check your network.

R7000使用hostIP获取到两个值,导致更新失败,提示postRS: Record line invalid

确认sh脚本及dns.conf文件 的编码为utf8
手动运行ddnspod.sh 提示
admin@R7000-56A2:/jffs/scripts# ./ddnspod.sh
Linux
./ddnspod.sh: line 96: command: not found
./ddnspod.sh: line 96: command: not found
./ddnspod.sh: line 96: command: not found
./ddnspod.sh: line 96: command: not found
./ddnspod.sh: line 96: command: not found
hostIP: 169.254.53.112 123.117.202.xx
lastIP:
postRS: Record line invalid

目测是由于获取到两个hostIP,第一个好像是个私有ip。
不知道如何解决,等待您的回复,谢谢!

如何设置多个IP

域名 *.example.com 需要添加 多个 IP,要怎么设置?

如果要分线路的话又要怎么设置?

ipv6更新失败

image

停留在这里
估摸着可能是是判断返回的是ip还是错误信息的地方有点问题

arDdnsRecordIp() {

local errMsg

local recordIp

# Get Record Ip
recordIp=$(arDdnsApi "Record.Info" "domain_id=$1&record_id=$2")
recordIp=$(echo $recordIp | sed 's/.*,"value":"\([0-9a-fA-F\.\:]*\)".*/\1/')

# Output Record Ip
case "$recordIp" in
    [1-9]*)
        echo $recordIp
        return 0
    ;;
    *)
        errMsg=$(echo $recordIp | sed 's/.*"message":"\([^\"]*\)".*/\1/')
        echo "arDdnsRecordIp - $errMsg"
        return 1
    ;;
esac

}

请问 ipv6 怎么用?

试一下,看到更新上去的是 ipv4 的址址,如果使用才能只把 ipv6 更新到 DDNS 中

ip addr list出现奇怪的vethhole

最近发现脚本刷的ip非常奇怪, ssh上去看了下ip -o -4 addr list发现有多了一条

9: vethhole inet 253.253.253.253/24 brd 253.253.253.255 scope global vethhole\ valid_lft forever preferred_lft forever

我暂时修改了 grep -Ev '\s(docker|lo|vethhole)'绕开了,不知有没有遇到过类似情况

运行出现Last Ip: arDdnsRecordIp - {"status":{"code":"8","message"无法更新IP

Fetching Host Ip

Host Ip: 119.129.XX.XX
Record Type: A
Fetching Ids of XXXXXX.tk
Domain Ids: 86670461 798518213
Checking Record for XXXXXX.tk
Last Ip: arDdnsRecordIp - {"status":{"code":"8","message":"\u8bb0\u5f55\u7f16\u53f7\u9519\u8bef","created_at":"2021-04-24 22:04:23"}}
Fetching Host Ip
Host Ip: 240e:3b4:ce:8360:3408:XXXX:XXXX:d4XX
Record Type: AAAA
Fetching Ids of XXXXXX.tk
Domain Ids: 86670461 798518282
Checking Record for XXXXXXXXd.tk
Last Ip: arDdnsRecordIp - {"status":{"code":"8","message":"\u8bb0\u5f55\u7f16\u53f7\u9519\u8bef","created_at":"2021-04-24 22:04:24"}}

请问是什么问题导致的,应该如何解决?
3Q

Get Record Info Failed!

2019-11-26
废弃修改资料、修改密码、修改邮箱、获取手机验证码四个用户相关接口
废弃D令牌验证相关参数
Domain.List、Record.List、Domain.Info、Record.Info四个接口新增返回字段
优化 API 调用频次限制,并增加频次说明。
调整了有问题的错误码

Not support Openwrt any more

@ProfFan

After #2 pull, using net device eth0 and using update dns method instead of ddns method, and this will failed in which does not have eth0 environment, such as Openwrt.

Because Openwrt using ppp0 for PPPOE, or eth0.1 as wan net devices, so script will failed when get ip address.

建议增加一键云运行脚本

使用云脚本,不用将脚本下载到本地,通过定时wget或者curl一键运行,参数可以在带到命令中而不用修改文件,我今天openwrt更新系统结果下载的脚本没了,然后就连接不上机器了

在macOS下上传IPv6地址时 会出现记录的值不正确

在macOS下sed 还是有些问题 加以 brew install gnu-sed 然后把脚本里的所有sed改为gsed
macOS下ip指令需要brew install iproute2mac。才能使用
macos在更新Ipv6地址时 脚本第86行有问题,默认获取的是ipv4地址导致的错误如下:
echo "Mac" arIpAddress() { #ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'#默认获取了ipv4地址 ip addr show dev en0 | gsed '/fe80/d' | gsed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d'| awk 'NR==1' }

line 96: command: not found

on Netgear R7000 & Merlin 380.57_X6.5

error message are below:

Linux                                                                         
./ddnspod.sh: line 96: command: not found
./ddnspod.sh: line 96: command: not found
./ddnspod.sh: line 96: command: not found
./ddnspod.sh: line 96: command: not found
./ddnspod.sh: line 96: command: not found
hostIP: xxx.xxx.xxx.xxx
lastIP:                          
postRS:xxx.xxx.xxx.xxx

postRS: Record line invalid

admin@CntR6300V2:/jffs/scripts# ./ddnspod.sh
Linux
./ddnspod.sh: line 96: command: not found
./ddnspod.sh: line 96: command: not found
./ddnspod.sh: line 96: command: not found
./ddnspod.sh: line 96: command: not found
./ddnspod.sh: line 96: command: not found
hostIP: 192.168.1.6 192.168.6.1
lastIP:
postRS: Record line invalid

我出现这写问题,我的路由器的上级路由器链接外网

arDdnsInfo 内对 recordIP 的判断有问题

您好,我在使用您的脚本时,发现无论如何都显示 Get Record Info Failed!
于是查看源码,注意到了在 127 行的判断

# Output IP
    case "$recordIP" in 
      [1-9][0-9]*) #我的远端设置是 0.0.0.0 ,大概是这个原因所以没有进入这个逻辑,我修改为 [0-9]* 就好了
        echo $recordIP
        return 0
        ;;
      *)
        echo "Get Record Info Failed!"
        return 1
        ;;
    esac

我对 shell 不熟悉,希望您能改善一下这个判断。

关于腾讯云

dnspod已被腾讯云收购整合完全了,无法进入控制台了,请更新兼容腾讯云,谢谢

修改了你的代码,增加了IPV6处理,我测试正常,版本归你!

#!/bin/sh

#################################################

AnripDdns v5.08

Dynamic DNS using DNSPod API

Original by anrip[email protected], http://www.anrip.com/ddnspod

Edited by ProfFan

#################################################

Openwrt

#################################################
#https://www.cnblogs.com/jackadam/p/8192843.html
#https://github.com/anrip/ArDNSPod
#1:必须安装CURL
#opkg --force-depends --force-overwrite install /tmp/libmbedtls_2.14.1-1_arm_cortex-a9.ipk
#opkg --force-depends --force-overwrite install /tmp/ca-bundle_20180409_all.ipk
#opkg --force-depends --force-overwrite install /tmp/libcurl_7.60.0-3_arm_cortex-a9.ipk
#opkg --force-depends --force-overwrite install /tmp/curl_7.60.0-3_arm_cortex-a9.ipk
#或者安装支持HTTPS的完整WGET
#2:拷贝ddnspod.sh和ddnspod.conf到相应的目录,并设置权限为777
#3:在/etc/ppp/ip-up.d目录新建一个文件autoddns.sh,权限0755,内容如下:

#/bin/sh

sh /etc/config/ddnspod.sh >> /tmp/log/dnspod.log 2>&1 &

#只要wan口发生变化,就会执行脚本去DNSpod更新A记录的IP。
#简单测试一下:/etc/init.d/network restart
#################################################

case $(uname) in
'Linux')
echo "Linux"
A() {
local extip
extip=$(ip -o -4 addr list | grep -Ev '\s(docker|lo)' | awk '{print $4}' | cut -d/ -f1 | grep -Ev '(^127.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$)|(^10.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$)|(^172.1[6-9]{1}[0-9]{0,1}.[0-9]{1,3}.[0-9]{1,3}$)|(^172.2[0-9]{1}[0-9]{0,1}.[0-9]{1,3}.[0-9]{1,3}$)|(^172.3[0-1]{1}[0-9]{0,1}.[0-9]{1,3}.[0-9]{1,3}$)|(^192.168.[0-9]{1,3}.[0-9]{1,3}$)')
if [ "x${extip}" = "x" ]; then
extip=$(ip -o -4 addr list | grep -Ev '\s(docker|lo)' | awk '{print $4}' | cut -d/ -f1 )
fi
echo $extip
}
getIPv6() {
local extip
extip=ip addr show ${ipv6ethName} | grep inet6 | awk '{print $2}' |grep ^${ipv6prefix} | grep '/64$' | sed 's/\/.*//g'
echo $extip
#ip addr show dev ${ipv6ethName} | sed -e's/^.inet6 ([^ ])/.*$/\1/;t;d'
#如果没有nvram,使用这条,注意将eth0改为本机上的网口设备(通过 ifconfig 查看网络接口)
}
# 获得外网ipv6地址
AAAA() {
local hostIP_v6=$(getIPv6)
while [[ -z $hostIP_v6 ]]
do
sleep 60
hostIP_v6=$(getIPv6)
done
echo $hostIP_v6
}
;;
*) ;;
esac

Get script dir

See: http://stackoverflow.com/a/29835459/4449544

rreadlink() ( # Execute the function in a subshell to localize variables and the effect of cd.

target=$1 fname= targetDir= CDPATH=

Try to make the execution environment as predictable as possible:

All commands below are invoked via command, so we must make sure that command

itself is not redefined as an alias or shell function.

(Note that command is too inconsistent across shells, so we don't use it.)

command is a builtin in bash, dash, ksh, zsh, and some platforms do not even have

an external utility version of it (e.g, Ubuntu).

command bypasses aliases and shell functions and also finds builtins

in bash, dash, and ksh. In zsh, option POSIX_BUILTINS must be turned on for that

to happen.

{ \unalias command; \unset -f command; } >/dev/null 2>&1
[ -n "$ZSH_VERSION" ] && options[POSIX_BUILTINS]=on # make zsh find builtins with command too.

while :; do # Resolve potential symlinks until the ultimate target is found.
[ -L "$target" ] || [ -e "$target" ] || { command printf '%s\n' "ERROR: '$target' does not exist." >&2; return 1; }
command cd "$(command dirname -- "$target")" # Change to target dir; necessary for correct resolution of target path.
fname=$(command basename -- "$target") # Extract filename.
[ "$fname" = '/' ] && fname='' # !! curiously, basename / returns '/'
if [ -L "$fname" ]; then
# Extract [next] target path, which may be defined
# relative to the symlink's own directory.
# Note: We parse ls -l output to find the symlink target
# which is the only POSIX-compliant, albeit somewhat fragile, way.
target=$(command ls -l "$fname")
target=${target#* -> }
continue # Resolve [next] symlink target.
fi
break # Ultimate target reached.
done
targetDir=$(command pwd -P) # Get canonical dir. path

Output the ultimate target's canonical path.

Note that we manually resolve paths ending in /. and /.. to make sure we have a normalized path.

if [ "$fname" = '.' ]; then
command printf '%s\n' "${targetDir%/}"
elif [ "$fname" = '..' ]; then
# Caveat: something like /var/.. will resolve to /private (assuming /var@ -> /private/var), i.e. the '..' is applied
# AFTER canonicalization.
command printf '%s\n' "$(command dirname -- "${targetDir}")"
else
command printf '%s\n' "${targetDir%/}/$fname"
fi
)

DIR=$(dirname -- "$(rreadlink "$0")")

Global Variables:

Token-based Authentication

arToken=""

Account-based Authentication

arMail=""
arPass=""
ipv6ethName=""
ipv6prefix=""

Load config

#. $DIR/ddnspod.conf

Get Domain IP

arg: domain

arDdnsInfo() {
recordType=$3
# Get domain ID
domainID=$(arApiPost "Domain.Info" "domain=${1}")
domainID=$(echo $domainID | sed 's/.{"id":"([0-9])".*/\1/')

# Get Record ID
recordID=$(arApiPost "Record.List" "domain_id=${domainID}&sub_domain=${2}&record_type=${recordType}")
recordID=$(echo $recordID | sed 's/.*\[{"id":"\([0-9]*\)".*/\1/')

# Last IP
recordIP=$(arApiPost "Record.Info" "domain_id=${domainID}&record_id=${recordID}&record_type=${recordType}")
recordIP=$(echo $recordIP | sed 's/.*,"value":"\([0-9a-z\.:]*\)".*/\1/')

# Output IP
case "$recordIP" in
  [0-9a-z]*)
    echo $recordIP
    return 0
    ;;
  *)
    echo "Get Record Info Failed,Please Install wget/curl or check your network or check domain/sub domain."
    return 1
    ;;
esac

}

Get data

arg: type data

arApiPost() {
local agent="AnripDdns/5.07([email protected])"
local inter="https://dnsapi.cn/${1:?'Info.Version'}"
if [ "x${arToken}" = "x" ]; then # undefine token
local param="login_email=${arMail}&login_password=${arPass}&format=json&${2}"
else
local param="login_token=${arToken}&format=json&${2}"
fi

if [ -n "`opkg list-installed | grep curl | sed 's/[[:space:]]//g'`" ];then #if install curl
    curl -k -X POST $inter -d "$param"
elif [ -n "`opkg list-installed | grep wget | sed 's/[[:space:]]//g'`" ];then  #if install wget          
    wget --quiet --no-check-certificate --output-document=- --user-agent=$agent --post-data $param $inter
else
    echo "Please run 'opkg install wget' or 'opkg install curl'!"
fi

}

Update

arg: main domain sub domain

arDdnsUpdate() {
local domainID recordID recordRS recordCD recordIP myIP recordType

recordType=$4
# Get domain ID
domainID=$(arApiPost "Domain.Info" "domain=${1}")
domainID=$(echo $domainID | sed 's/.*{"id":"\([0-9]*\)".*/\1/')
# Get Record ID
recordID=$(arApiPost "Record.List" "domain_id=${domainID}&sub_domain=${2}&record_type=${recordType}")
recordID=$(echo $recordID | sed 's/.*\[{"id":"\([0-9]*\)".*/\1/')
# Update IP
myIP=$3
recordRS=$(arApiPost "Record.Modify" "domain_id=${domainID}&sub_domain=${2}&record_type=${recordType}&record_id=${recordID}&record_line=%e9%bb%98%e8%ae%a4&value=${myIP}")
recordCD=$(echo $recordRS | sed 's/.*{"code":"\([0-9]*\)".*/\1/')
recordIP=$(echo $recordRS | sed 's/.*,"value":"\([0-9a-z\.:]*\)".*/\1/')
# Output IP
if [ "$recordIP" = "$myIP" ]; then
    if [ "$recordCD" = "1" ]; then
        echo $recordIP
        return 0
    fi
    # Echo error message
    echo $recordRS | sed 's/.*,"message":"\([^"]*\)".*/\1/'
    return 1
else
    echo "Update Failed! Please check your network."
    return 1
fi

}

DDNS Check

Arg: Main Sub

arDdnsCheck() {
if [ "x${3}" = "x" ]; then
recordType='A'
else
recordType=$3
fi
hostIP=$(${recordType})
echo "----------------------------------------"
echo "$(date "+%Y-%m-%d %H:%M:%S") Updating Domain: ${2}.${1} to ${hostIP}(${recordType})"
lastIP=$(arDdnsInfo $1 $2 $recordType)
if [ $? -eq 0 ]; then
echo "$(date "+%Y-%m-%d %H:%M:%S") lastIP: ${lastIP}"
if [ "$lastIP" != "$hostIP" ]; then
postRS=$(arDdnsUpdate $1 $2 $hostIP $recordType)
if [ $? -eq 0 ]; then
echo "$(date "+%Y-%m-%d %H:%M:%S") postRS: ${postRS}"
return 0
else
echo ${postRS}
return 1
fi
fi
echo "Last IP is the same as current IP!"
return 1
fi
echo ${lastIP}
return 1
}

DDNS

#echo ${#domains[@]}
#for index in ${!domains[@]}; do

echo "${domains[index]} ${subdomains[index]}"

arDdnsCheck "${domains[index]}" "${subdomains[index]}"

#done
. $DIR/ddnspod.conf

-----------ddnspod.conf-------------------
arToken="XXXXX,XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
ipv6ethName="pppoe-wan"
ipv6prefix="2409" #**移动IPV6前辍

arDdnsCheck "xxxxx.cn" "ipv4" #IPV4
arDdnsCheck "xxxxx.cn" "ipv6" "AAAA" #IPV6

Openwrt不知道怎么中间无法运行

放在路由上运行后wget报错
image 3

我试了有wget,安装bash在bash中运行也是一样的报错

image 4

后来换成CURL后成功了
image 5

image 6

按网上说的用crontab添加任务,结果找不到怎么编辑,用-e命令进入的是vim,完全不会操作,连退出都不会。
最后用WinSCP修改了/etc/crontab/root才成功了

`return 1` when the Last IP is same as current IP is unreasonable.

I use this script on my NAS server. And I use a task scheduler to execute it every 10 min.
When the script return 1 as a "Error Return", the NAS server will send me an e-mail to tell me "Hey, your script failed".
BUT , "the current IP same as last IP" is quite a normal thing. So it's more reasonable to return 0 as a successful return.

arWanIp 多网卡,获取到了两个ip,导致更新到api接口失败。

arWanIp 获取到了两个ip,导致更新到api接口失败。
最好是在获取ip之后对ip做个判断。如果你的lanIp获取有问题时候,执行下边的3322接口取ip

root@SAF:/etc/apps/ddns/dnspod# ./dnspod.sh
Updating Domain: sz-hs8145v..tk
Host Ip: 11.42.63.150 113.116.182.118
lastIP: 183.15.178.204
Host Ip^C
root@SAF:/etc/apps/ddns/dnspod# ./dnspod.sh
Updating Domain: sz-hs8145v.
.tk
Host Ip: 113.116.182.118
lastIP: 183.15.178.204
postRs: 113.116.182.118

可以在入口加个传参,不检索网卡ip,或者可以自己指定网卡名称过滤ip。
像路由器或者光猫这类,带拨号的,肯定会有多个ip,不一定是内网ip。有些双wan拨号。
openwrt 拨号网卡 ppp259

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.