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

暂无内容

阿里云 ddns

需求:

外网(公司,网吧,小黑屋)想访问自己家(闺蜜男友,………………)

家庭宽带,没有固定IP,重启一次猫/路由器,换一个IP

分析需求:

家里的宽带是动态公网IP 还是 小区局域网IP

检查方式:

浏览器打开ip138.com 看看自己的IP,记录下来

阿里云  ddns插图

浏览器打开自己路由器 ,例如(192.168.1.1 账号 密码)

阿里云  ddns插图1

两个红框相等 是公网动态IP(傻瓜式简单的愉快玩耍)

两个红框不等 是你们小区或者运营商的局域网IP (我劝你放弃,因为内网穿透,你会怀疑人生,虽然我会, 可是我不想说怎么做,现在请关闭浏览器,谢谢)

实现方法:

设置路由器端口转发,80端口别研究了,因为家用不给开放这个端口,如果非得玩, 自己找个服务器,做一个反向代理吧

mysql 3306 转发到你的电脑 192.168.250.250:3306

……

没条件呢, 用公网IP地址就可以访问了, 但是,重启路由的时候, 会更换IP, 自己勤看着点,穷屌丝

有条件的高富帅呢, 就去阿里云高额买个30左右一年的域名,做成动态DDNS, 以后访问域名就好了(重点)

这个是有,有杠精该说了, 买个花生壳不好么,我想跟你说 ,花生壳真的非常好, 你壕你去, no zuo no die ,why you try

买好域名, 自己去设置一下解析, 解析到 250.250.250.250

然后按照下面操作

https://github.com/verylaolu/aliyun_ddns

代码如下

package main import ( "encoding/json" "errors" "fmt" alidns20150109 "github.com/alibabacloud-go/alidns-20150109/v2/client" openapi "github.com/alibabacloud-go/darabonba-openapi/client" "github.com/alibabacloud-go/tea/tea" "github.com/jinzhu/configor" "io/ioutil" "math/rand" "net/http" "os" "os/exec" "path/filepath" "strings" "time" ) type OpenIP struct { Query string `json:"query"` } type Info struct { Access_key_id string Access_key_secret string RecordId string Domain_prefix string Path string } var Config = struct { Info }{} func main() { configor.Load(&Config, GetAppPath()+"/config.yml") err := _main(Config.Info) fmt.Println(err) } func _main (info Info) (_err error) { LocalIP :=getOpenIP() if(checkIP(LocalIP)==true){ client, _err := CreateClient(tea.String(info.Access_key_id), tea.String(info.Access_key_secret)) if _err != nil { return _err } updateDomainRecordRequest := &alidns20150109.UpdateDomainRecordRequest{ RecordId: tea.String(info.RecordId), RR: tea.String(info.Domain_prefix), Type: tea.String("A"), Value: tea.String(LocalIP), } _, _err = client.UpdateDomainRecord(updateDomainRecordRequest) if _err != nil { return _err } UpdateIP(LocalIP) return errors.New(" NEW LOCAL IP IS:"+LocalIP) }else{ return errors.New(" IP NOT CHANGE :"+LocalIP) } } func getOpenIP() string{ API_URL:="http://ip-api.com/json/" jsonstr := Get(API_URL) var Ip OpenIP json.Unmarshal(jsonstr, &Ip) return Ip.Query } func checkIP(ip string)bool{ content ,_ :=ioutil.ReadFile(GetAppPath()+"/ip.log") fmt.Println(ip+"==="+string(content)) if(ip==string(content)){ return false }else{ return true } } func UpdateIP(ip string){ ioutil.WriteFile(GetAppPath()+"/ip.log", []byte(ip),0666) } func CreateClient (accessKeyId *string, accessKeySecret *string) (_result *alidns20150109.Client, _err error) { config := &openapi.Config{ AccessKeyId: accessKeyId, AccessKeySecret: accessKeySecret, } config.Endpoint = tea.String("alidns.cn-hangzhou.aliyuncs.com") _result = &alidns20150109.Client{} _result, _err = alidns20150109.NewClient(config) return _result, _err } func randUA() string { var ua = make(map[int]string) ua[0] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36" ua[1] = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50" ua[2] = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50" ua[3] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1" ua[4] = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0" ua[5] = "Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11" ua[6] = "Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1" ua[7] = "Mozilla/5.0 (Linux; Android 4.1.2; Nexus 7 Build/JZ054K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19" ua[8] = "Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_4 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) CriOS/27.0.1453.10 Mobile/10B350 Safari/8536.25" ua[9] = "Mozilla/5.0 (compatible; WOW64; MSIE 10.0; Windows NT 6.2)" return ua[rand.Intn(10)] } func Get(url string) []byte { client := &http.Client{Timeout: time.Second * 60} req, err := http.NewRequest("GET", url, nil) if err != nil { fmt.Println(err) } userAgent := randUA() fmt.Println(userAgent) req.Header.Set("user-agent", userAgent) req.Header.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") req.Header.Add("Accept-Language", "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3") req.Header.Add("Referer", url) req.Header.Set("Content-Type", "application/json") resp, _ := client.Do(req) defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) return body } func GetAppPath() string { file, _ := exec.LookPath(os.Args[0]) path, _ := filepath.Abs(file) index := strings.LastIndex(path, string(os.PathSeparator)) return path[:index] } 

鄙人写的便宜廉价代码(GOLANG),完美解决阿里云域名 与你家IP链接的功能

傻瓜操作, 用就完了

按照代码介绍一运行, 去看看你的域名解析的IP是不是已经更改成你的公网IP

如果成功 ,你就可以开始愉快的玩耍了

如果失败,回到网站开头, 重新操作

原文链接:https://blog.csdn.net/lw503317/article/details/117064391?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168449620216800188544320%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=168449620216800188544320&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-20-117064391-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 分享