好物优选点击查看详情 京东购买

暂无内容

简单五步设置群晖NAS绑定自有域名实现外网访问

1.注册阿里云账号。
2.注册一个域名。
如果域名不在阿里云解析托管,需要先转过去,具体方法是联系域名提供商修改域名的DNS服务器,修改方式参考这里:https://help.aliyun.com/knowledge_detail/39844.html
然后去控制台找到云解析,将域名添加进去;
3.到阿里云控制中心找到access key和secret并保存下来(强烈建议遵循阿里云安全最佳实践的说明 ,使用RAM子用户的AccessKey);
4.到群晖控制中心找到任务计划新增一个计划。
新增->计划的任务->用户自定义脚本

简单五步设置群晖NAS绑定自有域名实现外网访问插图

设置10分钟定时

简单五步设置群晖NAS绑定自有域名实现外网访问插图1

复制以下内容,根据自己的情况修改中文部分并添加到任务设置自定义脚本

#!/bin/sh aliddns_name="你的域名前缀" aliddns_domain="你的域名" aliddns_ak="你的AccessKeyId" aliddns_sk="你的AccessKeySecret" aliddns_curl="curl -s whatismyip.akamai.com" aliddns_dns="8.8.8.8" aliddns_ttl="600" ip=`$aliddns_curl 2>&1` current_ip=`nslookup $aliddns_name.$aliddns_domain $aliddns_dns 2>&1` if [ "$?" -eq "0" ] then current_ip=`echo "$current_ip" | grep 'Address 1' | tail -n1 | awk '{print $NF}'` if [ "$ip" = "$current_ip" ] then exit 0 fi fi timestamp=`date -u "+%Y-%m-%dT%H%%3A%M%%3A%SZ"` urlencode() { # urlencode <string> out="" while read -n1 c do case $c in [a-zA-Z0-9._-]) out="$out$c" ;; *) out="$out`printf '%%%02X' "'$c"`" ;; esac done echo -n $out } enc() { echo -n "$1" | urlencode } send_request() { local args="AccessKeyId=$aliddns_ak&Action=$1&Format=json&$2&Version=2015-01-09" local hash=$(echo -n "GET&%2F&$(enc "$args")" | openssl dgst -sha1 -hmac "$aliddns_sk&" -binary | openssl base64) curl -s "http://alidns.aliyuncs.com/?$args&Signature=$(enc "$hash")" } get_recordid() { grep -Eo '"RecordId":"[0-9]+"' | cut -d':' -f2 | tr -d '"' } query_recordid() { send_request "DescribeSubDomainRecords" "SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&SubDomain=$aliddns_name.$aliddns_domain&Timestamp=$timestamp" } update_record() { send_request "UpdateDomainRecord" "RR=$aliddns_name&RecordId=$1&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&TTL=$aliddns_ttl&Timestamp=$timestamp&Type=A&Value=$ip" } add_record() { send_request "AddDomainRecord&DomainName=$aliddns_domain" "RR=$aliddns_name&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&TTL=$aliddns_ttl&Timestamp=$timestamp&Type=A&Value=$ip" } if [ "$aliddns_record_id" = "" ] then aliddns_record_id=`query_recordid | get_recordid` fi if [ "$aliddns_record_id" = "" ] then aliddns_record_id=`add_record | get_recordid` echo "added record $aliddns_record_id" else update_record $aliddns_record_id echo "updated record $aliddns_record_id" fi

简单五步设置群晖NAS绑定自有域名实现外网访问插图2
5.设置好端口转发。如何设置群晖端口转发请自行百度。

原文链接:https://blog.csdn.net/weixin_43858126/article/details/86529782?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168466843816800222846300%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=168466843816800222846300&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-15-86529782-null-null.blog_rank_default&utm_term=NAS%E3%80%81%E7%BE%A4%E6%99%96%E3%80%81%E9%98%BF%E9%87%8C%E4%BA%91%E3%80%81%E5%9F%9F%E5%90%8D%E8%A7%A3%E6%9E%90%E3%80%81%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F%E3%80%81ipv6%E3%80%81ddns%E3%80%81%E8%BD%BB%E9%87%8F%E7%BA%A7%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E3%80%81%E9%93%81%E5%A8%81%E9%A9%AC%E3%80%81%E5%A8%81%E8%81%94%E9%80%9A%E3%80%81DSM%E3%80%81DSM6.0%E3%80%81%E7%BE%A4%E6%99%96nas%E3%80%81%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E3%80%81%E8%9C%97%E7%89%9B%E6%98%9F%E9%99%85%E3%80%81%E9%BB%91%E7%BE%A4%E6%99%96%E3%80%81docker%E3%80%81%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E3%80%81%E5%9F%9F%E5%90%8D%E6%B3%A8%E5%86%8C%E3%80%81%E5%AE%9D%E5%A1%94%E3%80%81%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E3%80%81nginx%E3%80%81frp%E3%80%81%E5%8A%A8%E6%80%81%E5%9F%9F%E5%90%8D%E8%A7%A3%E6%9E%90

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享