找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 6743|回复: 132

[Router OS] ros通用ddns思路,兼容ipv6

 火.. [复制链接]
本帖最后由 伟大娃娃 于 2023-12-26 20:03 编辑

优点:

1、兼容性好,比如示例可以兼容
Cloudflare
Dnspod.cn
Dnspod.com国际版
Godaddy

2、不需要挠头写复杂脚本

实施步骤:

1、开启docker
2、使用UE-DDNShttps://blog.03k.org/post/ue-ddns.html)生成自己的ddns脚本,双栈就生成两个
3、使用其他docker服务器,将生成的一个或者多个ddns脚本放置到一个单独目录,并使用如下dockerfile生成docker
  1. # Use an official lightweight Linux distribution as a base image
  2. FROM alpine:latest

  3. # Set the working directory inside the container
  4. WORKDIR /app

  5. # Copy all Bash scripts in the current directory into the container at /app
  6. COPY *.sh /app/

  7. # Give execute permission to all scripts
  8. RUN chmod +x /app/*.sh

  9. # Specify the command to run on container startup
  10. ENTRYPOINT ["/bin/sh", "-c"]
  11. CMD ["/app/*.sh"]
复制代码
4、生成docker镜像并打包成tar格式
  1. docker build -t ddns-container .
  2. docker save -o ddns.tar ddns-container:latest
复制代码
5、上传此tar到file,并导入到container
  1. /container/add file=ddns.tar start-on-boot=yes interface=veth1
复制代码
6、scripts里配置ddns脚本
  1. :local hostname "xxx.right.com.cn"
  2. :local IPV4 [/ip address get [/ip address find interface=pppoe-out1] address]
  3. :set IPV4 [:pick $IPV4 0 ([len $IPV4] -3)]
  4. :if ([:resolve $hostname server=223.5.5.5] != $IPV4) do={
  5.   /container start 0
  6.   :log info "IPV4 Update: $hostname - $IPV4"
  7. }
复制代码
7、配置scheduler去增加一个任务,我设置的是15分钟

效果:
ros启动时或每15分钟自动执行检测ip变动时就会去执行此容器,此容器检测到IP变动(重复检测了当然无所谓嘛)就会去执行ddns任务,执行之后自动退出并不会占用系统资源。

参照此思路可以实现其他ddns服务商的ddns任务,也就是把写ros脚本的工作迁移到了写bash。

我的恩山、我的无线 The best wifi forum is right here.
几行脚本的事情被你搞成了docker,何苦来着。

点评

说的好啊 您分享几个ros7下的ddns脚本吧 比如我需求阿里云和dnspod 谢谢大佬  详情 回复 发表于 2023-12-26 20:02
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
mantouboji 发表于 2023-12-24 22:08
几行脚本的事情被你搞成了docker,何苦来着。

说的好啊 您分享几个ros7下的ddns脚本吧 比如我需求阿里云和dnspod 谢谢大佬

点评

点我的ID看我发表的帖子。  详情 回复 发表于 2023-12-26 20:47
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

伟大娃娃 发表于 2023-12-26 20:02
说的好啊 您分享几个ros7下的ddns脚本吧 比如我需求阿里云和dnspod 谢谢大佬

点我的ID看我发表的帖子。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

Cloudflare怎么搞?

点评

各种动态域名的更新都大同小异,都是用/tool/fetch去访问一个URL接口。无非是有的RESTFUL类型的接口用TOKEN,有的要用常规形式的web用户认证。 /tool fetch mode=https \\ http-method=put \\ url="https:/  详情 回复 发表于 2023-12-26 22:26
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报


各种动态域名的更新都大同小异,都是用/tool/fetch去访问一个URL接口。无非是有的RESTFUL类型的接口用TOKEN,有的要用常规形式的web用户认证。

/tool fetch mode=https \\
    http-method=put \\
    url="https://$HOST/client/v4/zones/$ZONE_ID/dns_records/$id" \\
    http-header-field="content-type: application/json,Authorization: Bearer $TOKEN" \\
    http-data="{\"type\":\"A\",\"name\":\"$name\",\"content\":\"\$mcdCurrentIP\"}" \\
    output=none
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

雀食,几行脚本就可以搞定。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

看看大神的攻略
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

学习下看看先
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

学习学习
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

bash -c "$(curl http://docker.xiaoya.pro/update_new.sh)" -s host
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

顶楼主啦..希望楼主多发精品好帖啦.....
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

学习下看看先 Cloudflare怎么搞?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

来自手机 | 显示全部楼层
持续多久小于恩师
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-29 16:55

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表