惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 【当耐特】
S
Schneier on Security
Blog — PlanetScale
Blog — PlanetScale
MyScale Blog
MyScale Blog
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
aimingoo的专栏
aimingoo的专栏
The GitHub Blog
The GitHub Blog
腾讯CDC
A
About on SuperTechFans
H
Help Net Security
The Register - Security
The Register - Security
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 三生石上(FineUI控件)
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Vercel News
Vercel News
V
Visual Studio Blog
T
Tailwind CSS Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - Franky
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
D
DataBreaches.Net
I
InfoQ
L
Lohrmann on Cybersecurity
M
MIT News - Artificial intelligence
I
Intezer
博客园 - 聂微东
Webroot Blog
Webroot Blog
宝玉的分享
宝玉的分享
Scott Helme
Scott Helme
Microsoft Security Blog
Microsoft Security Blog
SecWiki News
SecWiki News
Hacker News: Ask HN
Hacker News: Ask HN
T
Troy Hunt's Blog
S
Security @ Cisco Blogs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
N
Netflix TechBlog - Medium
小众软件
小众软件
The Cloudflare Blog
WordPress大学
WordPress大学
N
News | PayPal Newsroom
C
Check Point Blog
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
C
Cisco Blogs
阮一峰的网络日志
阮一峰的网络日志
W
WeLiveSecurity
Schneier on Security
Schneier on Security

林中阴影

林中阴影 | 关于蓝光刻录的一些调查 林中阴影 | 与IPv6地址战斗 林中阴影 | 半年前的NAS升级 林中阴影 | “智能” 家居笔记:一→两年后的回顾 林中阴影 | 旧手机做RDP客户端的一些尝试 林中阴影 | 一些矿渣的耗电量 林中阴影 | 穷人的IP-KVM远程访问 林中阴影 | 内网访问第三季:在运营商的CGNAT网络下 林中阴影 | “智能”家居笔记,其之二 林中阴影 | “智能”家居笔记,其之一 林中阴影 | 仅IPv6家庭内网服务实现v6+v4双栈访问 林中阴影 | 下载装小蜜监理拍摄的图片 林中阴影 | 几物互联 林中阴影 | 整了个“新”平板 林中阴影 | 获取招商信用卡账单的另一种方法 林中阴影 | 我在GitHub的⭐ 林中阴影 | Python与光学计算,2021 林中阴影 | 你可能并不需要内网穿透 林中阴影 | 2020 林中阴影 | 和(基本上)什么也不能连的电脑传递信息 林中阴影 | 我将贻笑于大方之家 林中阴影 | 一个新主题 林中阴影 | 2019过去了,我…… 林中阴影 | Beancount试用,半年后 林中阴影 | 自动输入剪贴板中的内容 林中阴影 | Unicode与数学公式 林中阴影 | Python中光学计算相关的库/Awesome Python for Optics 林中阴影 | 一本厕纸小说 林中阴影 | 震惊!为了在Windows上访问EXT4分区,他竟然做出了这样的事! 林中阴影 | 我的2018 林中阴影 | 笔记软件踩雷 林中阴影 | 关于BitMEX的杠杆 林中阴影 | 随机性从哪里来? 林中阴影 | 这次是纽约公共图书馆……而且居然还有第三部分? 林中阴影 | 这次是纽约公共图书馆……的第二天! 林中阴影 | 这次是纽约公共图书馆…… History Data for Bitcoin and Altcoins 林中阴影 | 幂律分布与Zipf's Law 林中阴影 | 学习笔记:神经网络的优化策略 林中阴影 | 最近对博客的改动 林中阴影 | 换了个新域名 林中阴影 | VPS初始化checklist 林中阴影 | 利用kcpraw流量加速 Aeolipile boiling: Your blog (with code and formula) on Steem! Aeolipile update: new theme, link generator and more! 林中阴影 | 离 林中阴影 | 社交恐惧症患者也想用Steem,所以我做了Aeolipile Aeolipile: your code and formula on Steem 林中阴影 | 2017年的fontconfig设置 林中阴影 | 为hugo加入数学公式支持 林中阴影 | 更琐碎的编辑器细节 / Some more trival details about Steemit 林中阴影 | 对Steem的一些细节考察 / A closer look to Steem 林中阴影 | 在Hugo中折叠部分内容 Brave New World: Firefox to Quantum Yesterday Once More: Firefox to Waterfox 林中阴影 | 首都图书馆半日游 林中阴影 | 关于那个IME helper Auto-Switch IME in Vim-Mode-Plus for Atom Editor 林中阴影 | 短消息:联通IPV6 林中阴影 | 迁移到hugo,第三部分:可是我想要更多的feed地址… 林中阴影 | 由wordpress到hugo:I 林中阴影 | 迁移到hugo,第二部分:部署到github 林中阴影 | Dota 2里,什么技能的冷却时间最短? 林中阴影 | 五年 林中阴影 | 为什么已经在Word里用M$的EMF格式了,图像还是不清楚? 林中阴影 | 用nethogs实时监控每个程序的流量使用 林中阴影 | shadowsocks 2016: 一次性认证,KCP及其他 林中阴影 | Deus ex machina 林中阴影 | QArt:更漂亮的QR码 林中阴影 | 我失去了heysh.tk域名 林中阴影 | 一个简单的在线LRC编辑器 林中阴影 | 野路子科研工具二则 林中阴影 | 我有显示器辣 林中阴影 | pentadactyl 和 Firefox 43 林中阴影 | 2014年的总结 林中阴影 | shadowsocks,ipv6和便宜的VPS,还有OpenVPN 林中阴影 | 红色楼梯 林中阴影 | 用于OPENWRT的流量监控脚本:wrtbwmon 林中阴影 | SFW:治疗拖延症的一次有益尝试 林中阴影 | 木漏れ日 林中阴影 | 一次奇怪的firefox故障,还有,一个普通市民是怎么修电脑的 林中阴影 | Mortal 林中阴影 | vim again 林中阴影 | 邪恶的Archlinux 林中阴影 | 十一年前,以及今天 林中阴影 | 贺叶霜的树 林中阴影 | Limited Gear Works 林中阴影 | 永生,其二 林中阴影 | 我的云上逃亡,或,google reader的替代品 林中阴影 | 如果你像我一样主力使用xfce但又觉得GNOME3也许会变得好一点于是安装之后才发现果然还是无法接受 林中阴影 | CATIA是个好软件 林中阴影 | blog再次复活 林中阴影 | 2012-2013 林中阴影 | Texlive 在archlinux上的安装,以及中文字体的设置 林中阴影 | phpwind论坛刷分脚本(可用于openwrt) 林中阴影 | THU课程表导出,油猴脚本,输出vcal 林中阴影 | html5-世界变动率计数器(仮) 林中阴影 | 总结:简单的vCal/iCalendar/.ics格式说明 林中阴影 | Hello Again~ 林中阴影 | chicken
林中阴影 | 用Cloudflare的v4 API实现动态DNS(DDNS)
2018-07-05 · via 林中阴影

如果你有一个经常变化的公网IP,你可能会需要用DDNS将这个IP绑定在同一个域名上,这样就可以不必每次输入一串IP地址了。我用的DNS服务商Cloudflare并没有提供名为DDNS的服务,但是其API可以实现类似的效果。

之前我用的是这里的方法,不过最近cloudflare更新了第四代API,那个方法已经失效。于是水博文的机会来了。

原料:

  1. 一个域名,并用Cloudflare管理
  2. 一台经常开着的,有计划任务或者cron,可以运行curl的电脑
  3. (可选)如果API地址被屏蔽的话,可能需要可用的代理

步骤:

  • https://dash.cloudflare.com/找到你域名的zone ID并新建一个~~API_KEY~~用于单个域名的API tokenAPI_KEY因为权限过高,不建议使用。
  • 新建一条子域名的A记录,IP写什么都行。
  • 查询这条记录的RECORD_ID,在终端运行:
curl -X GET "https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/dns_records" \
     -H "Authorization: Bearer <API token>" \
     -H "Content-Type: application/json" \
     -x http://localhost:8087

其中 -x是本地代理地址,可选。大概能从返回的一坨json中找到id那一项。

  • 保存下面的脚本,修改<ZONE_ID><RECORD_ID>邮箱地址API_KEY子域名什么的。如果不需要代理的话删除-x那一行。

IPv4的情况

#!/bin/sh
NEW_IP=$(curl http://members.3322.org/dyndns/getip)
CURRENT_IP=$(cat /var/tmp/current_ip.txt)
if [ "$NEW_IP" = "$CURRENT_IP" ]
then
     echo "No Change in IP Adddress"
else
     OUTPUT=$(curl -X PUT "https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/dns_records/<RECORD_ID>" \
     -x http://<代理地址,不要的话删去这一行>:8087 \
     -H "Authorization: Bearer <API token>" \
     -H "Content-Type: application/json" \
     --data '{"type":"A","name":"<子域名地址>","content":"'$NEW_IP'","ttl":1}')
     if echo "$OUTPUT" | grep -q "$NEW_IP"; then
          echo "Update IP Success!"
          echo $NEW_IP > /var/tmp/current_ip.txt
     else
          echo "Update Error!"
     fi
fi

IPv6的情况,放在两个不同的脚本里面可以共存

#!/bin/sh
NEW_IP=$(ip -6 addr | grep inet6 | grep -v deprecated | awk -F '[ \t]+|/' '{print $3}' | grep -v ^::1 | grep -v ^fe80 | head -n 1)
CURRENT_IP=$(cat /var/tmp/current_ip_6.txt)
if [ "$NEW_IP" = "$CURRENT_IP" ]
then
     echo "No Change in IP Adddress!"
else
     OUTPUT=$(curl -X PUT "https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/dns_records/<RECORD_ID>" \
     -x socks5h://<代理地址,不要的话删去这一行>:1085 \
     -H "Authorization: Bearer <API token>" \
     -H "Content-Type: application/json" \
     --data '{"type":"AAAA","name":"<子域名>.<域名>.xyz","content":"'$NEW_IP'","ttl":1}')
     if echo "$OUTPUT" | grep -q "$NEW_IP"; then
          echo "Update IP Success!"
          echo $NEW_IP > /var/tmp/current_ip_6.txt
     else
          echo "Update Error!"
     fi
fi
  • 接下来让它每两个小时运行一次就好了。
# crontab -e
*/120 * * * * /path/of/your/script.sh

写字好累(躺


来自19-10-25的更新:DNSpod的公网IP查询服务响应有些奇怪,所以换成了3322。

来自20-06-23:增加了判断,现在不会在一次网络问题后直接写入current_ip.txt了。