Giter Club home page Giter Club logo

cloudflare_update.script

此脚本为Mikrotik RouterOS update script for CloudFlare

前提条件

注意:脚本是基于RouterOS v6.46.4 编写的,大于小于此版本都可能导致一些命令问题

确认正确的公网地址

IPv4验证方法:

脚本提取 (WinBox –> IP –> Address List) 内指定接口的IP地址进行解析

ROS终端运行:/ip address get [/ip address find interface=接口名称] address

IPv6验证方法:

脚本提取 DHCPv6 Client 获取的 Prefix 并加上指定的IPv6后缀进行解析

ROS终端运行:/ipv6 dhcp-client get [find interface=接口名称] status

查看读出的数据是否为公网地址,

提前新建子域名

在 CloudFlare 新建需要解析的子域名,若需要解析IPv6和双栈还需要建立IPv4同名子域名和单独子域名,单独子域名用于IPv6是否更新的判断

ipv4.hscbook.com(A记录)

ipv4.hscbook.com(AAAA记录)

ipv6.hscbook.com(AAAA记录)

1、配置脚本

在 CloudFlare 域名主页的最下面 API 处

将 Zone ID 填入脚本的 CFzoneid 变量

点击 Get your API token 获取 API token 填入脚本的 CFtkn 变量

将 CloudFlare 的邮箱账号填入 CFemail 变量

根据三项信息套入

使用 cURL 获取 DNS Record ID

curl -X GET "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records" \

 -H "Content-Type: application/json" \
 
 -H "X-Auth-Key:$API_KEY" \
 
 -H "X-Auth-Email:$EMAIL"

并在 linux 终端中运行可取得子域名的 CFid 并填入 CFdomainid 变量

其他变量根据注释以实际情况自行修改后点击 Run Script 运行脚本测试,查看系统日志无报错即可

2、修改完毕,把script更新到ros需要添加如下执行权限:

*Read

*Write

*Test

*Sniff

*Sensitive

3、在ROS的system/scheduler添加一个轮训的计划任务:比如每五分钟执行一次

至此脚本全部设置完毕,看看是否更新。

END 参考文档:MikroTik Wiki 原脚本:Automatic script for Mikrotik RouterOS updating record on CloudFlare. 获取 CFid 可使用 API 调试工具,例:Postwoman(ApiDebug)

cola2050's Projects

chnroute-1 icon chnroute-1

Continuously updated list of Chinese IP addresses and gfwlist domain names

clash icon clash

Clash 肥羊订阅链接 自动更新

doprax1 icon doprax1

The tool can install v2ray on the Doprax, including VMess and VLess protocols, it will automatically switch IP, you need to fork this projects, read readme.md and run it. Create By ifeng.

herokuxray icon herokuxray

使用Heroku部署Xray高性能代理服务,通过ws传输的 (vmess、vless、trojan shadowsocks、socks)等协议

live icon live

✯ 一个可直连访问的电视/广播图标库与相关工具项目 ✯ 🔕 永久免费 直连访问 完整开源 不断完善的台标 支持IPv4/IPv6双栈访问 🔕

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.