whggo 发表于 2025-4-12 20:01:04

# OpenWrt 定时自动优选 IP 并 DDNS 解析<br />
<br />
!(<img id="aimg_nS3p0" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://openwrt.org/lib/tpl/openwrt/images/logo.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" />)<br />
<br />
一个用于 OpenWrt 路由器的自动化脚本,定时检查 有图比 可访问性,并在无法访问时自动优选 Cloudflare IP 并进行 DDNS 解析。<br />
<br />
## 功能特性<br />
<br />
- 定时检查 有图比 可访问性<br />
- 自动优选亚太地区 Cloudflare IP(香港、新加坡、日本、韩国)<br />
- 备用 IP 获取方案<br />
- 自动 DDNS 解析更新<br />
- 支持 Cloudflare 优选<br />
<br />
## 安装与配置<br />
<br />
### 基本配置<br />
<br />
1. 将以下脚本上传至路由器的 `/root` 目录:<br />
&nbsp; &nbsp;- `check_有图比.sh`<br />
&nbsp; &nbsp;- `yx.sh`<br />
&nbsp; &nbsp;- `getip.sh`<br />
&nbsp; &nbsp;- `hk/config.conf`<br />
<br />
2. 给予脚本执行权限:<br />
&nbsp; &nbsp;```bash<br />
&nbsp; &nbsp;chmod +x /root/*.sh<br />
&nbsp; &nbsp;chmod +x /root/hk/config.conf<br />
&nbsp; &nbsp;```<br />
<br />
3. 配置定时任务(每15分钟运行一次):<br />
&nbsp; &nbsp;```bash<br />
&nbsp; &nbsp;*/15 * * * * cd /root &amp;&amp; bash check_有图比.sh<br />
&nbsp; &nbsp;```<br />
<br />
### 文件配置说明<br />
<br />
#### 1. `getip.sh` 配置<br />
- 替换文件中的 DDNS 信息为您自己的配置<br />
<br />
#### 2. `hk/config.conf` 配置<br />
- 替换文件中的信息为您自己的配置<br />
<br />
#### 3. CloudflareST 文件<br />
- 根据您的系统架构,下载合适的 CloudflareST 版本并替换 `cf_ddns/` 目录下的文件<br />
<br />
## 脚本说明<br />
<br />
### 主要脚本<br />
<br />
- **check_有图比.sh**&nbsp;&nbsp;<br />
&nbsp;&nbsp;主检查脚本,每15分钟运行一次,检查 有图比 可访问性<br />
<br />
- **yx.sh**&nbsp;&nbsp;<br />
&nbsp;&nbsp;主要优选脚本:<br />
&nbsp;&nbsp;- 下载白**哥的 IP 库进行优选测速<br />
&nbsp;&nbsp;- 优选亚太地区 IP(香港、新加坡、日本、韩国)<br />
&nbsp;&nbsp;- 将优选结果解析到 DDNS<br />
<br />
- **getip.sh**&nbsp;&nbsp;<br />
&nbsp;&nbsp;备用 IP 获取脚本:<br />
&nbsp;&nbsp;- 从 (https://www.wetest.vip/page/cloudflare/address_v4.html) 获取第6个IP(联通线路)<br />
&nbsp;&nbsp;- 进行 DDNS 解析<br />
<br />
### 工作流程<br />
<br />
1. 每15分钟检查 有图比 可访问性<br />
2. 当 有图比 无法访问时:<br />
&nbsp; &nbsp;- 尝试运行 `yx.sh` 优选 IP<br />
&nbsp; &nbsp;- 如果 IP 库无法下载,则运行 `getip.sh` 获取备用 IP<br />
3. 将优选/获取的 IP 更新到 DDNS 解析<br />
<br />
## 注意事项<br />
<br />
1. 请确保您的 OpenWrt 系统已安装必要的依赖(如 wget, curl 等)<br />
2. 根据您的网络环境调整优选策略<br />
3. 建议初次使用时手动运行脚本检查效果<br />
4. 定期检查脚本是否正常运行<br />
<br />
## 许可证<br />
<br />
本项目采用 MIT 许可证。详细信息请参阅项目中的 LICENSE 文件。<br />
<br />
---<br />
<br />
**作者**: net5705632&nbsp;&nbsp;<br />
**仓库地址**: (https://github.com/net5705632/openwrt_yxip)

zh000323 发表于 2025-4-12 20:16:11

我不想分享<br />
自己写一个吧<br />
<img id="aimg_baCHd" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="https://img.imotao.com/i/2025/04/13/67fb1b0e214e0.jpg" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" />
页: 1 [2]
查看完整版本: CF优选IP能不能弄成全自动的每天自动选一个最好的写入ho'sts