使用CloudFlare搭建DDNS

·
日常 VMware var cloudflare 脚本 install python 文件 目录 the host txt yaml config you're October 7, 2020

最近准备入手一个Raspberry Pi,用来替代oray(没实名,10月17号就停止解析),为了防止翻车,先在VMware上测试

CloudFlare DDNS

CloudFlare本身没有官方的DDNS支持,但可以使用CloudFlare API实做,我找了一个别人做好的CloudFlare-ddns,折腾一会儿就搭建好了。

首先从GitHub clone

git clone https://github.com/thatjpk/cloudflare-ddns.git

进入目录

cd cloudflare-ddns/

安装依赖

pip install -r requirements.txt

重命名config.yaml.template文件

mv config.yaml.template config.yaml

修改config.yaml

nano config.yaml

差不多是这样的:

%YAML 1.2
# CloudFlare DDNS updater script config.
---

# CloudFlare API key
# You can find this under Account > My account after logging into CloudFlare.
cf_key: 'cloudflare的API密钥'

# Email address for your CloudFlare account.
cf_email: '注册时使用的邮箱'

# Domain you're using CloudFlare to manage.
# If the host name you're updating is "ddns.domain.com", make this "domain.com".
cf_domain: '填入根域名'

# The subdomain you're using for your DDNS A record.
# If the host name you're updating is "ddns.domain.com", make this "ddns".
# However, if you're updating the A record for the naked domain (that is, just
# "domain.com" without a subdomain), then set cf_subdomain to an empty value.
cf_subdomain: '填入子域名'

# CloudFlare service mode. This enables/disables CF's traffic acceleration.
# Enabled (orange cloud) is 1. Disabled (grey cloud) is 0.
cf_service_mode: 0

# If set to true, prints a message only when the record changes or when
# there's an error.  If set to 'false', prints a message every time even if
# the record didn't change.
quiet: false

# If set to true then we call the ec2metadata service for the instance
# public ip address rather than an external service.
aws_use_ec2metadata: false

# If set to true dig will be used to fetch the public IP which is better
# but not available on all systems.
use_dig: false

创建子域名

略

运行脚本

python cloudflare_ddns.py config_file_name.yaml

添加定时任务

crontab -e

填入如下内容

# Every 15 minutes, check the current public IP, and update the A record on CloudFlare.
*/15 * * * * /path/to/code/cloudflare_ddns.py /path/to/code/config.yaml >> /var/log/cloudflare_ddns.log

完成后每15分钟就会向cloudflare上传一次IP

  • 光电鼠标工作原理和结构介绍
  • CRT显示器和LCD 显像原理
取消回复

说点什么?
Title
首先从GitHub clone
进入目录
安装依赖
重命名config.yaml.template文件
修改config.yaml
差不多是这样的:
创建子域名
运行脚本
添加定时任务

© 2023 Type boom
友链&RSS