1 Star 2 Fork 1

KenGe / aliyun-ddns-shell

forked from risfeng / aliyun-ddns-shell 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

阿里云域名动态IP解析Shell小脚本

当你手里面有一个闲置的域名,有一个漂浮不定的外网ip,你又想在外网ip变更后自动解析到域名上,此情此景此脚本可能会帮上你。


使用步骤:

  • 在阿里云域名管理中解析自己的域名
    • 记录类型:A
    • 主机记录:按你需要输入
    • 解析路线:默认(随你)
    • 记录值:随便输入一个Ip地址(运行脚本后会自动更新到正确的)
    • TTL值:10分钟
  • 需要通过阿里云域名解析Api操作,所以需要申请阿里云的Acesskeys
  • 运行自动解析域名脚本
    • git clone https://gitee.com/KenGe/aliyun-ddns-shell.git
    • 给aliyun-ddns.sh脚本赋可执行权:chmod +x aliyun-ddns-shell/src/aliyun/aliyun-ddns.sh
    • 运行脚本,根据提示进行配置(第一次运行需要配置)
    • 如需要使用钉钉自定义机器人推送成功失败消息,请新建自定义钉钉机器人,配置access_token和消息加签密钥
    • 脚本支持2种运行方式:
      • 直接运行脚本根据提示选择需要使用的功能
      > aliyun-ddns.sh (mac: > bash aliyun-ddns.sh)
      1.配置并执行脚本
      2.仅配置
      3.仅执行脚本
      4.恢复出厂设置
      5.清理日志文件
      0.退出
      • 带参数运行:
      aliyun-ddns.sh -config -run     配置并执行脚
      aliyun-ddns.sh -run             执行脚本(前提需要有配置文件)
      aliyun-ddns.sh -config          仅配置信息
      aliyun-ddns.sh -restore         恢复出厂设置(会清除配置文件等)
      aliyun-ddns.sh -clearn          清理日志文件
      aliyun-ddns.sh -version         显示脚本说明及版本信息
  • 实时监听外网IP变更后自动解析到域名
    • 利用定时任务服务:crond
    • 检测是否安装:crond -V 有输出版本号即已安装。
    • 如未安装:yum install vixie-cron crontabs -y 如有疑问请自行查找资料解决
    • crond服务常用命令
    service crond status   # 查看服务运行状态  
    service crond start    # 启动服务
    service crond stop     # 停止服务 
    service crond restart  # 重启服务  
    service crond reload   # 不中断服务,重新载入配置 
    crontab -e             # 编辑配置文件 
    crontab -l             # 列出某个用户的任务计划
    • 配置任务定时任务
      • 建议不要把任务执行频率设置小于等10,因为域名解析记录生效时间最短理论上是10分钟,往往都会超过10分,建议15-20分钟。
      • 开始配置
      crontab -e
      # 按i进入标记模式
      # 输入:
      */20 * * * * XXXXXX/aliyun-ddns-shell/src/aliyun/aliyun-ddns.sh -run >> XXXX/aliyun-ddns-shell/src/aliyun/crontab-log.log
      # 说明:
      # */20 * * * * :每20分钟执行一次 需要执行都脚本全路径 >> 执行日志输出位置全路径
      # 按 esc 后 输入:wq 回车 保存并退出
      • 重新加载配置:service crond reload
      • 注意观察任务是否成功执行,如有疑问请自行百度

效果图

启动页面 配置页面 运行页面

欢迎star给予支持

MIT License Copyright (c) 2020 risfeng Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

阿里云域名动态IP解析Shell小脚本 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/KenGe/aliyun-ddns-shell.git
git@gitee.com:KenGe/aliyun-ddns-shell.git
KenGe
aliyun-ddns-shell
aliyun-ddns-shell
master

搜索帮助