{"id":466,"date":"2022-03-31T12:56:13","date_gmt":"2022-03-31T04:56:13","guid":{"rendered":"https:\/\/cqiot.cc\/?p=466"},"modified":"2022-04-14T16:31:22","modified_gmt":"2022-04-14T08:31:22","slug":"ddns%e8%87%aa%e5%8a%a8%e8%8e%b7%e5%be%97%e4%bd%a0%e7%9a%84%e5%85%ac%e7%bd%91-ipv4-%e6%88%96-ipv6-%e5%9c%b0%e5%9d%80%ef%bc%8c%e5%b9%b6%e8%a7%a3%e6%9e%90%e5%88%b0%e5%af%b9%e5%ba%94%e7%9a%84%e5%9f%9f","status":"publish","type":"post","link":"https:\/\/cqiot.cc\/index.php\/2022\/03\/31\/ddns%e8%87%aa%e5%8a%a8%e8%8e%b7%e5%be%97%e4%bd%a0%e7%9a%84%e5%85%ac%e7%bd%91-ipv4-%e6%88%96-ipv6-%e5%9c%b0%e5%9d%80%ef%bc%8c%e5%b9%b6%e8%a7%a3%e6%9e%90%e5%88%b0%e5%af%b9%e5%ba%94%e7%9a%84%e5%9f%9f\/","title":{"rendered":"DDNS-go\u81ea\u52a8\u83b7\u5f97\u4f60\u7684\u516c\u7f51 IPv4 \u6216 IPv6 \u5730\u5740\uff0c\u5e76\u89e3\u6790\u5230\u5bf9\u5e94\u7684\u57df\u540d\u670d\u52a1Alidns(\u963f\u91cc\u4e91)\u00a0Dnspod(\u817e\u8baf\u4e91)\u00a0Cloudflare\u00a0\u534e\u4e3a\u4e91\u00a0Callback"},"content":{"rendered":"\n<p>\u65e0\u610f\u4e2d\u770b\u5230\u7684\u4e00\u4e2aDDNS\u5de5\u5177\u770b\u7740\u8fd8\u4e0d\u9519  \u8bb0\u5f55\u4e00\u4e0b\u3002\u3002\u9879\u76ee\u5730\u5740https:\/\/rat.dev\/jeessy2\/ddns-go<\/p>\n\n\n\n<ul class=\"wp-block-list\" id=\"block-8f9e6610-bb18-4337-b3bb-7d5eb2db8127\"><li>\u652f\u6301Mac\u3001Windows\u3001Linux\u7cfb\u7edf\uff0c\u652f\u6301ARM\u3001x86\u67b6\u6784<\/li><li>\u652f\u6301\u7684\u57df\u540d\u670d\u52a1\u5546&nbsp;<code>Alidns(\u963f\u91cc\u4e91)<\/code>&nbsp;<code>Dnspod(\u817e\u8baf\u4e91)<\/code>&nbsp;<code>Cloudflare<\/code>&nbsp;<code>\u534e\u4e3a\u4e91<\/code>&nbsp;<code>Callback<\/code><\/li><li>\u652f\u6301\u63a5\u53e3\/\u7f51\u5361\u83b7\u53d6IP<\/li><li>\u652f\u6301\u4ee5\u670d\u52a1\u7684\u65b9\u5f0f\u8fd0\u884c<\/li><li>\u9ed8\u8ba4\u95f4\u96945\u5206\u949f\u540c\u6b65\u4e00\u6b21<\/li><li>\u652f\u6301\u591a\u4e2a\u57df\u540d\u540c\u65f6\u89e3\u6790\uff0c\u516c\u53f8\u5fc5\u5907<\/li><li>\u652f\u6301\u591a\u7ea7\u57df\u540d<\/li><li>\u7f51\u9875\u4e2d\u914d\u7f6e\uff0c\u7b80\u5355\u53c8\u65b9\u4fbf\uff0c\u53ef\u8bbe\u7f6e&nbsp;<code>\u767b\u5f55\u7528\u6237\u540d\u548c\u5bc6\u7801<\/code>&nbsp;\/&nbsp;<code>\u7981\u6b62\u4ece\u516c\u7f51\u8bbf\u95ee<\/code><\/li><li>\u7f51\u9875\u4e2d\u65b9\u4fbf\u5feb\u901f\u67e5\u770b\u6700\u8fd150\u6761\u65e5\u5fd7\uff0c\u4e0d\u9700\u8981\u8dd1docker\u4e2d\u67e5\u770b<\/li><li>\u652f\u6301webhook\u901a\u77e5<\/li><li>\u652f\u6301TTL<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u7cfb\u7edf\u4e2d\u4f7f\u7528<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u4e0b\u8f7d\u5e76\u89e3\u538b<a href=\"https:\/\/rat.dev\/jeessy2\/ddns-go\/releases\">https:\/\/github.com\/jeessy2\/ddns-go\/releases<\/a><\/li><li>\u53cc\u51fb\u8fd0\u884c, \u5982\u6ca1\u6709\u627e\u5230\u914d\u7f6e, \u7a0b\u5e8f\u81ea\u52a8\u6253\u5f00<a href=\"http:\/\/127.0.0.1:9876\/\">http:\/\/127.0.0.1:9876<\/a><\/li><li>[\u53ef\u9009] \u5b89\u88c5\u670d\u52a1<ul><li>Mac\/Linux:&nbsp;<code>sudo .\/ddns-go -s install<\/code><\/li><li>Win(\u4ee5\u7ba1\u7406\u5458\u6253\u5f00cmd):&nbsp;<code>.\\ddns-go.exe -s install<\/code><\/li><li>\u5b89\u88c5\u670d\u52a1\u4e5f\u652f\u6301&nbsp;<code>-l<\/code>\u76d1\u542c\u5730\u5740&nbsp;<code>-f<\/code>\u540c\u6b65\u95f4\u9694\u65f6\u95f4(\u79d2)&nbsp;<code>-c<\/code>\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u8def\u5f84<\/li><\/ul><\/li><li>[\u53ef\u9009] \u670d\u52a1\u5378\u8f7d<ul><li>Mac\/Linux:&nbsp;<code>sudo .\/ddns-go -s uninstall<\/code><\/li><li>Win(\u4ee5\u7ba1\u7406\u5458\u6253\u5f00cmd):&nbsp;<code>.\\ddns-go.exe -s uninstall<\/code><\/li><\/ul><\/li><li>[\u53ef\u9009] \u652f\u6301\u542f\u52a8\u5e26\u53c2\u6570&nbsp;<code>-l<\/code>\u76d1\u542c\u5730\u5740&nbsp;<code>-f<\/code>\u540c\u6b65\u95f4\u9694\u65f6\u95f4(\u79d2)&nbsp;<code>-c<\/code>\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\u3002\u5982\uff1a<code>.\/ddns-go -l 127.0.0.1:9876 -f 600 -c \/Users\/name\/ddns-go.yaml<\/code><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/rat.dev\/jeessy2\/ddns-go#docker%E4%B8%AD%E4%BD%BF%E7%94%A8\"><\/a>Docker\u4e2d\u4f7f\u7528<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u4e0d\u6302\u8f7d\u4e3b\u673a\u76ee\u5f55, \u5220\u9664\u5bb9\u5668\u540c\u65f6\u4f1a\u5220\u9664\u914d\u7f6e# host\u6a21\u5f0f, \u540c\u65f6\u652f\u6301IPv4\/IPv6, Liunx\u7cfb\u7edf\u63a8\u8350 docker run -d &#8211;name ddns-go &#8211;restart=always &#8211;net=host jeessy\/ddns-go # \u6865\u63a5\u6a21\u5f0f, \u53ea\u652f\u6301IPv4, Mac\/Windows\u7cfb\u7edf\u63a8\u8350 docker run -d &#8211;name ddns-go &#8211;restart=always -p 9876:9876 jeessy\/ddns-go<\/li><li>\u5728\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00<code>http:\/\/\u4e3b\u673aIP:9876<\/code>\uff0c\u4fee\u6539\u4f60\u7684\u914d\u7f6e\uff0c\u6210\u529f<\/li><li>[\u53ef\u9009] \u6302\u8f7d\u4e3b\u673a\u76ee\u5f55, \u5220\u9664\u5bb9\u5668\u540e\u914d\u7f6e\u4e0d\u4f1a\u4e22\u5931\u3002\u53ef\u66ff\u6362&nbsp;<code>\/opt\/ddns-go<\/code>&nbsp;\u4e3a\u4e3b\u673a\u76ee\u5f55, \u914d\u7f6e\u6587\u4ef6\u4e3a\u9690\u85cf\u6587\u4ef6docker run -d &#8211;name ddns-go &#8211;restart=always &#8211;net=host -v \/opt\/ddns-go:\/root jeessy\/ddns-go<\/li><li>[\u53ef\u9009] \u652f\u6301\u542f\u52a8\u5e26\u53c2\u6570&nbsp;<code>-l<\/code>\u76d1\u542c\u5730\u5740&nbsp;<code>-f<\/code>\u95f4\u9694\u65f6\u95f4(\u79d2)docker run -d &#8211;name ddns-go &#8211;restart=always &#8211;net=host jeessy\/ddns-go -l :9877 -f 600<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/rat.dev\/jeessy2\/ddns-go#%E4%BD%BF%E7%94%A8ipv6\"><\/a>\u4f7f\u7528IPv6<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u524d\u63d0\uff1a\u4f60\u7684\u7535\u8111\u6216\u7ec8\u7aef\u80fd\u6b63\u5e38\u83b7\u53d6IPv6\uff0c\u5e76\u80fd\u6b63\u5e38\u8bbf\u95eeIPv6<\/li><li>Windows\/Mac\uff1a\u63a8\u8350&nbsp;<a href=\"https:\/\/rat.dev\/jeessy2\/ddns-go#%E7%B3%BB%E7%BB%9F%E4%B8%AD%E4%BD%BF%E7%94%A8\">\u7cfb\u7edf\u4e2d\u4f7f\u7528<\/a>\uff0cWindows\/Mac\u684c\u9762\u7248\u7684docker\u4e0d\u652f\u6301<code>--net=host<\/code><\/li><li>\u7fa4\u6656\uff1a<ul><li>\u5957\u4ef6\u4e2d\u5fc3\u4e0b\u8f7ddocker\u5e76\u6253\u5f00<\/li><li>\u6ce8\u518c\u8868\u4e2d\u641c\u7d22<code>ddns-go<\/code>\u5e76\u4e0b\u8f7d<\/li><li>\u6620\u50cf -&gt; \u9009\u62e9<code>jeessy\/ddns-go<\/code>&nbsp;-&gt; \u542f\u52a8 -&gt; \u9ad8\u7ea7\u8bbe\u7f6e -&gt; \u7f51\u7edc\u4e2d\u52fe\u9009<code>\u4f7f\u7528\u4e0e Docker Host \u76f8\u540c\u7684\u7f51\u7edc<\/code>\uff0c\u9ad8\u7ea7\u8bbe\u7f6e\u4e2d\u52fe\u9009<code>\u542f\u52a8\u81ea\u52a8\u91cd\u65b0\u542f\u52a8<\/code><\/li><li>\u5728\u6d4f\u89c8\u5668\u4e2d\u6253\u5f00<code>http:\/\/\u7fa4\u6656IP:9876<\/code>\uff0c\u4fee\u6539\u4f60\u7684\u914d\u7f6e\uff0c\u6210\u529f<\/li><\/ul><\/li><li>Linux\u7684x86\u6216arm\u67b6\u6784\uff0c\u63a8\u8350\u4f7f\u7528Docker\u7684<code>--net=host<\/code>\u6a21\u5f0f\u3002\u53c2\u8003&nbsp;<a href=\"https:\/\/rat.dev\/jeessy2\/ddns-go#Docker%E4%B8%AD%E4%BD%BF%E7%94%A8\">Docker\u4e2d\u4f7f\u7528<\/a><\/li><li>\u865a\u62df\u673a\u4e2d\u4f7f\u7528\u6709\u53ef\u80fd\u6b63\u5e38\u83b7\u53d6IPv6\uff0c\u4f46\u4e0d\u80fd\u6b63\u5e38\u8bbf\u95eeIPv6<\/li><li>[\u53ef\u9009] \u4f7f\u7528IPv6\u540e\uff0c\u5efa\u8bae\u52fe\u9009<code>\u7981\u6b62\u4ece\u516c\u7f51\u8bbf\u95ee<\/code><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/rat.dev\/jeessy2\/ddns-go#webhook\"><\/a>Webhook<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u652f\u6301webhook, \u57df\u540d\u66f4\u65b0\u6210\u529f\u6216\u4e0d\u6210\u529f\u65f6, \u4f1a\u56de\u8c03\u586b\u5199\u7684URL<\/li><li>\u652f\u6301\u7684\u53d8\u91cf\u53d8\u91cf\u540d\u8bf4\u660e#{ipv4Addr}\u65b0\u7684IPv4\u5730\u5740#{ipv4Result}IPv4\u5730\u5740\u66f4\u65b0\u7ed3\u679c:&nbsp;<code>\u672a\u6539\u53d8<\/code>&nbsp;<code>\u5931\u8d25<\/code>&nbsp;<code>\u6210\u529f<\/code>#{ipv4Domains}IPv4\u7684\u57df\u540d\uff0c\u591a\u4e2a\u4ee5<code>,<\/code>\u5206\u5272#{ipv6Addr}\u65b0\u7684IPv6\u5730\u5740#{ipv6Result}IPv6\u5730\u5740\u66f4\u65b0\u7ed3\u679c:&nbsp;<code>\u672a\u6539\u53d8<\/code>&nbsp;<code>\u5931\u8d25<\/code>&nbsp;<code>\u6210\u529f<\/code>#{ipv6Domains}IPv6\u7684\u57df\u540d\uff0c\u591a\u4e2a\u4ee5<code>,<\/code>\u5206\u5272<\/li><li>RequestBody\u4e3a\u7a7aGET\u8bf7\u6c42\uff0c\u4e0d\u4e3a\u7a7aPOST\u8bf7\u6c42<\/li><li>Server\u9171:&nbsp;<code>https:\/\/sc.ftqq.com\/[SCKEY].send?text=\u4e3b\u4ebaIPv4\u53d8\u4e86#{ipv4Addr},\u57df\u540d\u66f4\u65b0\u7ed3\u679c:#{ipv4Result}<\/code><\/li><li>Bark:&nbsp;<code>https:\/\/api.day.app\/[YOUR_KEY]\/\u4e3b\u4ebaIPv4\u53d8\u4e86#{ipv4Addr},\u57df\u540d\u66f4\u65b0\u7ed3\u679c:#{ipv4Result}<\/code><\/li><li>\u9489\u9489:<ul><li>\u9489\u9489\u7535\u8111\u7aef -&gt; \u7fa4\u8bbe\u7f6e -&gt; \u667a\u80fd\u7fa4\u52a9\u624b -&gt; \u6dfb\u52a0\u673a\u5668\u4eba -&gt; \u81ea\u5b9a\u4e49<\/li><li>\u53ea\u52fe\u9009&nbsp;<code>\u81ea\u5b9a\u4e49\u5173\u952e\u8bcd<\/code>, \u8f93\u5165\u7684\u5173\u952e\u5b57\u5fc5\u987b\u5305\u542b\u5728RequestBody\u7684content\u4e2d, \u5982\uff1a<code>\u4f60\u7684\u516c\u7f51IP\u53d8\u4e86<\/code><\/li><li>URL\u4e2d\u8f93\u5165\u9489\u9489\u7ed9\u4f60\u7684&nbsp;<code>Webhook\u5730\u5740<\/code><\/li><li>RequestBody\u4e2d\u8f93\u5165&nbsp;<code>{\"msgtype\": \"text\",\"text\": {\"content\": \"\u4f60\u7684\u516c\u7f51IP\u53d8\u4e86\uff1a#{ipv4Addr}\uff0c\u57df\u540d\u66f4\u65b0\u7ed3\u679c\uff1a#{ipv4Result}\"}}<\/code><\/li><\/ul><\/li><li>Telegram:&nbsp;<a href=\"https:\/\/rat.dev\/WingLim\/ddns-telegram-bot\">ddns-telegram-bot<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/rat.dev\/jeessy2\/ddns-go#callback\"><\/a>Callback<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u901a\u8fc7\u81ea\u5b9a\u4e49\u56de\u8c03\u53ef\u652f\u6301\u66f4\u591a\u7684\u7b2c\u4e09\u65b9DNS\u670d\u52a1\u5546<\/li><li>\u914d\u7f6e\u7684\u57df\u540d\u6709\u51e0\u884c, \u5c31\u4f1a\u56de\u8c03\u51e0\u6b21<\/li><li>\u652f\u6301\u7684\u53d8\u91cf\u53d8\u91cf\u540d\u8bf4\u660e#{ip}\u65b0\u7684IPv4\/IPv6\u5730\u5740#{domain}\u5f53\u524d\u57df\u540d#{recordType}\u8bb0\u5f55\u7c7b\u578b&nbsp;<code>A<\/code>\u6216<code>AAAA<\/code>#{ttl}ttl<\/li><li>RequestBody\u4e3a\u7a7aGET\u8bf7\u6c42\uff0c\u4e0d\u4e3a\u7a7aPOST\u8bf7\u6c42<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/rat.dev\/jeessy2\/ddns-go#%E7%95%8C%E9%9D%A2\"><\/a>\u754c\u9762<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/raw.rat.dev\/jeessy2\/ddns-go\/master\/ddns-web.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-495\" src=\"https:\/\/cqiot.cc\/wp-content\/uploads\/2022\/03\/ddns-web.png\" width=\"1066\" height=\"1020\" alt=\"ddns-web\" title=\"ddns-web\" srcset=\"https:\/\/cqiot.cc\/wp-content\/uploads\/2022\/03\/ddns-web.png 1066w, https:\/\/cqiot.cc\/wp-content\/uploads\/2022\/03\/ddns-web-300x287.png 300w, https:\/\/cqiot.cc\/wp-content\/uploads\/2022\/03\/ddns-web-1024x980.png 1024w, https:\/\/cqiot.cc\/wp-content\/uploads\/2022\/03\/ddns-web-768x735.png 768w, https:\/\/cqiot.cc\/wp-content\/uploads\/2022\/03\/ddns-web-660x632.png 660w\" sizes=\"auto, (max-width: 1066px) 100vw, 1066px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/rat.dev\/jeessy2\/ddns-go#%E5%BC%80%E5%8F%91%E8%87%AA%E8%A1%8C%E7%BC%96%E8%AF%91\"><\/a>\u5f00\u53d1&amp;\u81ea\u884c\u7f16\u8bd1<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5982\u679c\u559c\u6b22\u4ece\u6e90\u4ee3\u7801\u7f16\u8bd1\u81ea\u5df1\u7684\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528\u672c\u9879\u76ee\u63d0\u4f9b\u7684 Makefile \u6784\u5efa<\/li><li>\u5f00\u53d1\u73af\u5883 golang 1.17<\/li><li>\u4f7f\u7528&nbsp;<code>make build<\/code>&nbsp;\u751f\u6210\u672c\u5730\u7f16\u8bd1\u540e\u7684&nbsp;<code>ddns-go<\/code>&nbsp;\u53ef\u6267\u884c\u6587\u4ef6<\/li><li>\u4f7f\u7528&nbsp;<code>make build_docker_image<\/code>&nbsp;\u81ea\u884c\u7f16\u8bd1 Docker \u955c\u50cf<\/li><\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u65e0\u610f\u4e2d\u770b\u5230\u7684\u4e00\u4e2aDDNS\u5de5\u5177\u770b\u7740\u8fd8\u4e0d\u9519 \u8bb0\u5f55\u4e00\u4e0b\u3002\u3002\u9879\u76ee&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-466","post","type-post","status-publish","format-standard","hentry","category-route"],"_links":{"self":[{"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/posts\/466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/comments?post=466"}],"version-history":[{"count":2,"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/posts\/466\/revisions"}],"predecessor-version":[{"id":468,"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/posts\/466\/revisions\/468"}],"wp:attachment":[{"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/media?parent=466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/categories?post=466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cqiot.cc\/index.php\/wp-json\/wp\/v2\/tags?post=466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}