A simple, lightweight and asynchronous application that updates Cloudflare DNS records when your IP address changes.
- Written in Rust
- Fully Asynchronous
- Lightweight
- Configurable
To build this program from source, you'll need the Rust Toolchain. It's easily installable from RustUp for Windows and Unix. It can be simply installed on Unix by running the following command provided that you have curl installed.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Run theese commands one by one as root. A short description of what theese commands will do:
- Clone the source code
- Build the binary
- Move the binary, example config and service config to the correct location
- Reload, enable and start the service
cd /tmp
git clone https://github.com/SamHDev/cloudflare-record-updater
cd cloudflare_updater
cargo build --release
mv target/release/cloudflare_updater /usr/bin/cloudflare_updater
mkdir /etc/cloudflare_updater/
mv install/ExampleConfig.Toml /etc/cloudflare_updater/Config.Toml
mv install/cloudflare_updater.service /sys/systemd/system/cloudflare_updater.service
sudo systemctl daemon-reload
sudo systemctl enable cloudflare_updater
## CONFIGURE THE APPLIACTION
## sudo nano /etc/cloudflare_updater/Config.Toml
sudo systemctl start cloudflare_updater
rm -r /tmp/cloudflare_updater
Please get a Cloudflare API token from the Cloudflare dashboard.
This appliaction requires Zone.Zone
, Zone.DNS
with edit permissions
-
Go to the Cloudflare dashboard API tokens page
-
Create Token
-
Create Custom Token
-
Set Token name
-
Add the following in the Permissions section
Zone Zone Read
Zone DNS Edit
-
Continue to Summary
-
Make sure you have
All zones - DNS:Edit, Zone:Read
-
Create token
-
Copy the token
You can edit the configuration using an terminal editor like nano
.
The default location of the config /etc/cloudflare_updater/Config.Toml
You can edit it by running this command:
sudo nano /etc/cloudflare_updater/Config.Toml
The configuration is in the TOML format, which makes it highly readable and easy to understand.
- The API KEY for cloudflare to use.
- Paste in the value aqauired from the instructions above.
- Make sure to keep the
'
on either side to make it a valid string.
- The IP 'grabber' service to use.
- Current services are:
- ipify
- The Interval to query the IP and update records in seconds.
- Can be any number between 1-4294967295.
- Either 60, 120 or 300 is recommended for a decent update time.
- The records to update via cloudflare.
- In the format
<record>.<domain>
. - For example, the domain
gamersite.tk
has a recordhome
, the valid name would behome.gamersite.tk
.
A sample configuration with non-real examples
api_key = 'ENTER_KEY_HERE'
service = 'ipify'
interval = 300
names = ["server.example.com"]
A sample configuration with more realastic examples
api_key = 'RGJtHeULFELunHmSncnhbjuzGQERcNutGCKTDoaL'
service = 'ipify'
interval = 120
names = ["home.gamersite.tk", "house.gamersite.tk"]