1.修改openw*r*t web https管理端口为8443
修改ipv6 https 监听端口list listen_https '[::]:8443'
cd /etc/config/
vi uhttpd
vi /etc/config/uhttpd
config uhttpd 'main'
list listen_http '0.0.0.0:80'
list listen_http '[::]:80'
list listen_https '0.0.0.0:443'
list listen_https '[::]:8443'
option redirect_https '0'
option home '/www'
option rfc1918_filter '1'
option max_requests '3'
option max_connections '100'
option cert '/etc/uhttpd.crt'
option key '/etc/uhttpd.key'
option cgi_prefix '/cgi-bin'
list lua_prefix '/cgi-bin/luci=/usr/lib/lua/luci/sgi/uhttpd.lua'
option script_timeout '60'
option network_timeout '30'
option http_keepalive '20'
option tcp_keepalive '1'
option ubus_prefix '/ubus'
list index_page 'cgi-bin/luci'
config cert 'defaults'
option days '730'
option key_type 'ec'
option bits '2048'
option ec_curve 'P-256'
option country 'ZZ'
option state 'Somewhere'
option location 'Unknown'
option commonname 'OpenWrt'
2.dnspod自动解析本地wan6 ipv6地址
#!/bin/sh
# DNSPod Token 的 ID
ID=175***
# DNSPod Token ID 所对应的 Token
Token=c7e3081b0c8eeda1e*************
# DDNS 的主域名,例如 ascn.site
domain=qq.com
# DDNS 的域名记录,例如 blog
record=blog
# DDNS 的类型,允许的值为 A 或者 AAAA
record_type=AAAA
# 检测出口 IP 的 API,可选输入,例如 ip.sb,或者我所搭建的 ip.leao9203.xyz,建议优先自己搭建一个
ip_api=$(ip -6 addr show pppoe-wan | grep 'inet6' | grep -v 'fe80:' | awk '{print $2}' | cut -d '/' -f1)
echo $ip_api
# 是否忽略 IP 变化,强制更新。如果启用,请设置为 true
force=false
# 获取输入参数
while getopts i:k:d:r:t:a:f: opts; do
case ${opts} in
i) ID=${OPTARG} ;;
k) Token=${OPTARG} ;;
d) domain=${OPTARG} ;;
r) record=${OPTARG} ;;
t) record_type=${OPTARG} ;;
a) ip_api=${OPTARG} ;;
f) force=${OPTARG} ;;
*) echo "无效参数,请重新输入" && exit 1 ;;
esac
done
if [ "${ID}" = "" ]; then
echo "请输入 DNSPod Token 的 ID"
echo "可从这里获取 https://console.dnspod.cn/account/token/token"
exit 1
fi
if [ "${Token}" = "" ]; then
echo "请输入 DNSPod Token ID 所对应的 Token 值"
echo "可从这里获取 https://console.dnspod.cn/account/token/token"
exit 1
fi
if [ "${domain}" = "" ]; then
echo "请输入域名"
echo "例如 ascn.site"
exit 1
fi
if [ "${record}" = "" ]; then
echo "请输入记录值"
echo "例如 blog.ascn.site"
echo "则输入 blog"
exit 1
fi
if [ "${record_type}" = "" ]; then
echo "请输入记录类型 A | AAAA"
exit 1
fi
if [ "${ip_api}" = "" ]; then
echo "请输入获取 IP 的 API"
echo "例如 ip.leao9203.xyz"
exit 1
fi
if [ "${force}" = "" ]; then
echo "请确认是否强制更新 true | false"
exit 1
fi
# 本机 IP
ip=
# 获取 IP
if [ "${record_type}" = "AAAA" ]; then
#ip=$(curl -s -6 "${ip_api}" | grep -v %)
##获取 pppoe-wan接口上的IPV6地址
ip=$(ip -6 addr show pppoe-wan | grep 'inet6' | grep -v 'fe80:' | awk '{print $2}' | cut -d '/' -f1)
echo $ip
elif [ "${record_type}" = "A" ]; then
ip=$(curl -s -4 "${ip_api}" | grep -v %)
fi
# 运行目录,以及 IP 文件
config_path=dnspod-ddns
ip_file=${config_path}/${record}.${domain}.ip.txt
# 判断是否存在配置目录
if [ ! -d "${config_path}" ]; then
mkdir -p "${config_path}"
fi
# 判断是否存在 IP 文件、IP 是否更改
if [ ! -f "${ip_file}" ]; then
echo "${ip}" >> "${ip_file}"
elif [ "$(cat "${ip_file}")" = "${ip}" ] && [ ! "${force}" = true ]; then
echo "IP 未改变,将不进行更新"
exit 0
fi
# 组合出 DNSPod 的新鉴权 API
#curl https://dnsapi.cn/Domain.List -d "login_token=175***,c7e3081b0c8eeda1e68******&format=json"
login_token=${ID},${Token}
#创建域名解析
curl -X POST https://dnsapi.cn/Record.Create -d 'login_token=${login_token}&format=json&domain_id=93845109&sub_domain=${record}&record_type=AAAA&record_line_id=10%3D0&value=1.1.1.1'
echo $login_token
# 获取 DNSPod 的记录 ID
#record_id=$(curl -s -X POST https://dnsapi.cn/Record.List -d "login_token=${login_token}" -d "domain=${domain}" -d "format=xml" | grep -B 6 "${record}" | grep id | sed -e 's/<[^>]*>//g')
record_id=$(curl -s -X POST https://dnsapi.cn/Record.List -d "login_token=${login_token}" -d "domain=${domain}" -d "format=xml")
curl -s -X POST https://dnsapi.cn/Record.List -d "login_token=${login_token}" -d "domain=${domain}" -d "format=xml"
echo $record_id
# 更新 IP
#*/10 * * * * /root/dnspod-ddns.sh 添加定时任务
#echo "login_token=${login_token}&domain=${domain}&format=xml&record_id=${record_id}&sub_domain=${record}&record_type=${record_type}&record_line_id=0&value=${ip}"
curl -s -X POST https://dnsapi.cn/Record.Modify -d "login_token=${login_token}&domain=${domain}&format=xml&record_id=1532596793&sub_domain=${record}&record_type=${record_type}&record_line_id=0&value=${ip}"
3.定时任务
*/10 * * * * /root/dnspod-ddns.sh
<?xml version="1.0" encoding="UTF-8"?>
<dnspod>
<status>
<code>1</code>
<message><![CDATA[操作已经成功完成]]></message>
<created_at>2023-07-03 18:17:54</created_at>
</status>
<record>
<id>1532596793</id>
<name>mkjy</name>
<value>2409:8a38:b202:******************:ddc6</value>
<status>enable</status>
<weight></weight>
</record>
</dnspod>
文章来源:https://www.toymoban.com/news/detail-534321.html
文章来源地址https://www.toymoban.com/news/detail-534321.html
到了这里,关于open*w*r*t +dnspod ddns动态解析ipv6 远程控制移动内网路由器的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!