开始
natmap是一个stun穿透的工具,可以穿透并保活端口,我家里是nat1可以用它来搞mc服务器
mc java版支持srv记录,可以直接把natmap的端口参数直接传到脚本里ddns更新端口
先获取RECORD值
curl -s -X GET "https://api.cloudflare.com/client/v4/zones/${ZONE}/dns_records“\
-H "X-Auth-Email: ${EMAIL}" \
-H "Authorization: Bearer ${AUTH}" \
-H "Content-Type: application/json"
然后用这个更新srv记录,cf的TARGET只能绑域名
还要再ddns一个A记录,因为是nat只能用别的url来获取ip
我用的国内的,省的去加绕过名单 https://ddns.oray.com/checkip
#!/bin/sh
ZONE=''
RECORD=''
EMAIL=''
AUTH=''
NAME='mc.xxxxx.xxx'
TARGET='mm.xxxxx.xxx'
PORT=${2}
while true; do
curl -X PUT "https://api.cloudflare.com/client/v4/zones/${ZONE}/dns_records/${RECORD}" \
-H "X-Auth-Email: ${EMAIL}" \
-H "Authorization: Bearer ${AUTH}" \
-H "Content-Type: application/json" \
--data '{
"type": "SRV",
"ttl": 60,
"data": {
"service": "_minecraft",
"proto": "_tcp",
"name": "'"$NAME"'",
"priority": 0,
"weight": 5,
"port": '"$PORT"',
"target": "'"$TARGET"'"
}
}' # >/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
break
fi
done
结束
在/etc/rc.local启动项加
natmap -d -i pppoe-wan -s stunserver.stunprotocol.org -h qq.com -b 8001 -t 192.168.31.111 -p 25565 -e /ddns/mc_srv.sh
是openwrt可以直接在官方源安装luci-app-natmap
记得要放行端口
Comments 1 条评论
博主 mozi1924
哎呀,忘记可以用markdown语法了,记得email我或者去我10月31号那篇博客看