Cloudflare dynamic DNS daemon for x86 / ARMv7 (Raspberry Pi support)
986
homerun is a tool which updates an A record on Cloudflare whenever your public IP changes
This is useful when you want to access services hosted on your home pc/homelab whilst having a dynamic IP
Docker
Clone the repo::
git clone https://github.com/ocanty/homerun.git cd homerun
Build the Docker image, note the arguments
For x86 based OS's::
sudo docker build . --build-arg SUBDOMAIN=homerun --build-arg DOMAIN=example.com --build-arg PROXY=false --build-arg UPDATE_EVERY=10 -t my-homerun
For armv7 based OS's::
sudo docker build -f Dockerfile.armv7 . --build-arg SUBDOMAIN=homerun --build-arg DOMAIN=example.com --build-arg PROXY=false --build-arg UPDATE_EVERY=10 -t my-homerun
Setup Cloudflare API keys
Follow Cloudflare instructions to retrieve your API key <https://support.cloudflare.com/hc/en-us/articles/200167836-Where-do-I-find-my-Cloudflare-API-key->_.Run the image first to test, to see if everything is working correctly::
sudo docker run -t -e "CF_API_EMAIL=" -e "CF_API_KEY=" my-homerun
If so, set it up to fork to the background::
sudo docker run -e "CF_API_EMAIL=" -e "CF_API_KEY=" my-homerun &
(optional) If you do not want to pass Cloudflare keys as environment variables, you can follow Step 5 below, and then rebuild the image as before with .cloudflare.cfg in the project directory.
Manual
Clone the repo::
git clone https://github.com/ocanty/homerun.git
Install dependencies::
python3 setup.py install
Edit config.yml and setup configuration (example below)::
ip_server: https://ifconfig.co/ip subdomain: homerun domain: example.com proxy: false update_every: 10
Specify config options as you wish
ip_server - A HTTP(S) service that when GET requested, returns the IP of the client (you probably won't need to change this)
subdomain - The subdomain you want to point to your home IP
domain - A Cloudflare site that is associated with your Cloudflare account
proxy - Should we proxy this record through Cloudflare's system? (If this is true note that Cloudflare only supports some ports based on your plan)
update_every - Check every x amount of minute for an IP change
Setup Cloudflare API keys
Follow Cloudflare instructions to retrieve your API key <https://support.cloudflare.com/hc/en-us/articles/200167836-Where-do-I-find-my-Cloudflare-API-key->_.
Create a file named .cloudflare.cfg in the project directory (the folder with setup.py, requirements.txt...)
The file should look like as follows::
[CloudFlare] email = token =
For more information about this click here <https://github.com/cloudflare/python-cloudflare#providing-cloudflare-username-and-api-key>_.
Setup the systemd service
Edit homerun.service, changing WorkingDirectory to the path you placed the repo::
[Unit] Description=homerun - dynamic DNS daemon for Cloudflare
[Service] Type=simple WorkingDirectory=/home/ocanty/projects/homerun/ ExecStart=python3 homerun.py ExecStop=pkill -f 'python3 homerun.py'
[Install] WantedBy=multi-user.target
Tell systemd to use the service::
sudo ln -s homerun.service /etc/systemd/system/homerun.service systemctl enable homerun.service systemctl start homerun.service
Your record should be up and running at subdomain.domain
What if I want it to point to the root? i.e just domain
You should make use of Cloudflare's CNAME flattening feature <https://blog.cloudflare.com/introducing-cname-flattening-rfc-compliant-cnames-at-a-domains-root/>_ to alias this subdomain to the root domain.
What about other subdomains?
Just use regular CNAMEs.
Content type
Image
Digest
Size
35.6 MB
Last updated
over 7 years ago
docker pull ocanty/homerun