The Cloudflare IP Updater is a Go-based application that updates Cloudflare DNS A records whenever your public IP address changes. This ensures that your domain always points to your current IP address. The updater runs as a background process, checking your IP address every 2 minutes.
- Periodically checks your public IP address.
- Updates Cloudflare DNS A records if the IP address has changed.
- Runs as a lightweight service.
- Can be deployed using Docker.
- Go 1.21.4 or later (for building from source).
- Docker (for containerized deployment).
- Cloudflare account with API key and appropriate permissions.
To ensure the application can identify and update the correct Cloudflare DNS A records, include the {filter}
value in the comment of each DNS record you want to be updated. Follow these steps:
-
Log in to your Cloudflare account.
-
Navigate to the DNS settings of your domain.
-
Locate the A records you want the application to update.
-
Edit the A records:
-
Save the changes to the DNS records.
By adding the {filter}
value to the comments of the DNS records, the application can accurately identify which records to update based on the filter you provide when running the application.
To use the Cloudflare IP Updater, you need to generate an API token with the necessary permissions. Follow these steps to create an API token:
-
Log in to your Cloudflare account.
-
Go to the API Tokens page:
- Click on your profile icon in the top right corner.
- Select My Profile from the dropdown menu.
- Navigate to the API Tokens tab.
-
Create a new API token:
- Click on Create Token.
-
Configure the API token:
- Under Custom Token, click on Get started.
-
Set up permissions:
-
Specify the zone resources:
- Choose All Zones if you want the token to have access to all your zones.
- Otherwise, select Specific Zone and specify the zone you want to manage.
-
Complete the setup:
- Give your token a descriptive name.
- Optionally, set an expiration date for the token.
-
Create and save the token:
- Click on Continue to summary.
- Review the token settings.
- Click on Create Token.
- Copy the generated API token and store it securely. You will need this token to authenticate the Cloudflare IP Updater.
By following these steps, you will have a Cloudflare API token with the necessary permissions to update DNS records. Use this token as the auth_key
when running the Cloudflare IP Updater.
The Zone Identifier (Zone ID) is a unique identifier for your domain in Cloudflare. You need this ID to configure the Cloudflare IP Updater. Follow these steps to obtain the Zone Identifier:
-
Log in to your Cloudflare account.
-
Select the domain for which you need the Zone Identifier:
- From the Cloudflare dashboard, click on the domain name in the list of your sites.
-
Find the Zone Identifier:
- Once you are on the Overview page for your domain, scroll down to the API section on the right-hand side.
- Here, you will see the Zone ID.
-
Copy the Zone Identifier:
- Click on the Copy button next to the Zone ID to copy it to your clipboard.
You will use this Zone Identifier as the zone_identifier
parameter when running the Cloudflare IP Updater.
-
Clone the repository:
git clone https://github.com/your-repo/cloudflare-ip-updater.git cd cloudflare-ip-updater
-
Build the application:
go build -o cloudflare-ip-updater
-
Run the application:
./cloudflare-ip-updater -zone_identifier your_zone_id -auth_key your_auth_key -filter your_filter
-
Clone the repository:
git clone https://github.com/your-repo/cloudflare-ip-updater.git cd cloudflare-ip-updater
-
Build the Docker image:
docker build -t cloudflare-ip-updater:latest .
-
Run the Docker container:
docker run -d --name cloudflare-ip-updater \ cloudflare-ip-updater:latest \ -zone_identifier your_zone_id -auth_key your_auth_key -filter your_filter
-
Clone the repository:
git clone https://github.com/your-repo/cloudflare-ip-updater.git cd cloudflare-ip-updater
-
Create a
.env
file with your configuration:ZONE_IDENTIFIER=your_zone_id AUTH_KEY=your_auth_key FILTER=your_filter
-
Run the application using Docker Compose:
docker-compose up -d
-zone_identifier
: Cloudflare Zone Identifier (required)-filter
: Cloudflare A record filter (required)-auth_key
: Cloudflare Authentication Key (required)
./cloudflare-ip-updater -zone_identifier your_zone_id -auth_key your_auth_key -filter your_filter
docker run -d --name cloudflare-ip-updater \
cloudflare-ip-updater:latest \
-zone_identifier your_zone_id -auth_key your_auth_key -filter your_filter
Create a .env
file with your configuration values. Then, run:
docker-compose up -d
- The application reads the required flags (
zone_identifier
,filter
, andauth_key
). - It validates the presence of required flags.
- It initializes a
CloudflareService
instance. - A Goroutine checks the current IP address every 2 minutes.
- If the IP address has changed, it updates the Cloudflare DNS A records.
main()
: The entry point of the application.checkRequiredFlags()
: Validates the presence of required flags.
Feel free to submit issues, fork the repository, and send pull requests.
This project is licensed under the MIT License. See the LICENSE
file for details.