Code Monkey home page Code Monkey logo

dynamic-cloud-dns-client's Introduction

Dynamic Cloud DNS Client

This is a simple client for the Dynamic Cloud DNS project.

Designed to run under Linux systemd, it consists of a small Python script, which uses the ipify API to retrieve the current IP and if the IP address has changed, calls the cloud function configured as per the instructions for Dynamic Cloud DNS.

Prerequisites

Needs Python 3, requests and backoff

pip3 install -r requirements.txt

Setup

  • Copy dynamic_cloud_dns_client.py to /usr/local/bin
  • Copy [email protected] to /etc/systemd/system
  • Copy dynamic_cloud_dns_client_your.host to /etc (replace your.host with your actual hostname)
  • Edit dynamic_cloud_dns_client_your.host and fill in the environment variables
  • Enable and start your service: systemctl enable [email protected]

Run sudo ./install.sh your.host to do the first 3 steps. Run just sudo ./install.sh to do the first two steps.

Testing

Probably a good idea to do this in a virtualenv:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install -t test-requirements.txt
pytest

License

Copyright (c) 2020, Paul Adams. All rights reserved.

DCDNS Client is licensed under the MIT License.

See LICENSE for more details.

dynamic-cloud-dns-client's People

Contributors

crazystick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

dynamic-cloud-dns-client's Issues

config file - better explanation of variables

# the Cloud DNS zone to update
DCDNS_ZONE=**_MYHOST_**

https://console.cloud.google.com/net-services/dns/zones/**_MYHOST_**/details?project=myexampleproject

is it a proper mapping?

the DNS hostname to update, e.g. your.host.com

DCDNS_HOST=dynamichost.domain.com

https://console.cloud.google.com/net-services/dns/zones/**_MYHOST_**/rrsets/your.host.com./A/view?project=myexampleproject

is it a proper mapping?

the URL of your deployed cloud function

DCDNS_FUNCTION_URL=https://us-central1-myexampleproject .cloudfunctions.net/updateHost
cant figure out where to find "us-central1" i have got
https://console.cloud.google.com/compute/instances?project=myexampleproject => Zone = "northamerica-northeast2-a" is it the same ?

client sometimes gets stuck

logs entries like

DEBUG    urllib3.connectionpool    Starting new HTTPS connection (1): api.ipify.org

then nothing

Typo in install.sh echoed instructions

In install.sh the line:

echo "Edit /etc/dynamic_cloud_dns_client_$1 and then run systemctl enable dynamic_cloud_dns_client@$1.service"

should have dashes rather than underscores for "dynamic-cloud-dns-client@$1.service".

Otherwise when someone copies and pastes the message to enable the service they naturally get an error.

Request to ipify should have retry logic

If the request to ipify fails for any reason, it raises an error, which causes the main loop to exit, and systemd is responsible for restarting it.

It would be much better if there was at least an attempt to retry the request before failing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.