GithubHelp home page GithubHelp logo

hellstromit / do-dyndns Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 1.0 69 KB

App to update DigitalOcean DNS dynamically

License: GNU General Public License v3.0

Go 66.52% Dockerfile 7.21% Mustache 26.27%
dyndns dns nsupdate golang dynamic-dns dynamic-dns-updater digitalocean-dns do-dyndns

do-dyndns's Introduction

Docker Pulls

do-dynds

Small Go application to automatically update a digitalocean DNS entry with your public IP (dyndns).

This application is intended to run as a docker container or a kubernetes deployment but can be ran standalone. It's also possible to deploy the container alongside your application by adding it to the same pod.

Containers can be found at: https://hub.docker.com/r/hellstromitltd/do-dyndns

Why?

Exposing applications to the internet in an environment where you don't have a static IP can be tricky. DNS is usually an issue since your public IP can change at any time. There's multiple dyndns providers available but this application specifically handles a situation where your DNS is in DigitalOcean.

Configuration

Check the config.yml.example file for an example configuration.

Create a digitalocean token at https://cloud.digitalocean.com/account/api/tokens and make sure it has Write permission. Optionally set an expiration, I'd suggest doing it but keep in mind that when the expiry date is reached you'll need to create a new token and update your configuration.

Variable Description
interval Defines at what intervals we should check our public IP
ifconfig Holds the host and uri for the service used to check the public IP
digitalocean Holds the digitalocean API token. The token can also be set as an environment variable DO_TOKEN
domains A list of domains that should be updated in DigitalOcean DNS

In the example https://api.ipify.org/?format=json is used to query for the public IP but any service that gives a json response with the ip parameter should work.

Preparing the DNS

Any missing A records will be automatically created by the application. Just make sure that the domain is setup in https://cloud.digitalocean.com/networking/domains

The application will ONLY update or create records that are defined in the config.yml. Other records that are manually added will be left alone.

Deploying

Compiling

It's possible to run the application standalone by compiling it manually (there's currently no pre-built binaries)

To compile the application checkout this repository:

git checkout https://github.com/HellstromIT/do-dyndns.git

Enter the app directory and run the following command

cd app
go build -o do-dyndns cmd/do-dyndns/main.go 

This should give you a binary called do-dyndns that you can copy to your path.

Note that since the application is currently focused on running within a docker container the config.yml file will need to be located in the /data/ directory. That is the data directory in the root of your filesystem.

Running the container

To run the container in docker there's two ways. The first is to run it with docker run and the second is using a docker-compose file.

In both cases you will need to mount the config.yml into the container at /data/config.yml.

Docker run

Start by creating a config.yml file in your current directory. Use the included example as a base. Omit the digitalocean configuration if you plan to supply the token as an environment variable.

Then run the following command (token in config.yml)

docker run --name do-dyndns -d -v $(pwd)/config.yml:/data/config.yml hellstromitltd/do-dyndns:v0.1.1

Or this command if you prefer supplying the digitalocean token as an environment variable

docker run --name do-dyndns -d -v $(pwd)/config.yml:/data/config.yml --env DO_TOKEN=<your digitalocean token> hellstromitltd/do-dyndns:v0.1.1

The docker logs for the container will inform you if a domain has changed.

Compose

A docker compose file is available in the repository and can be used to deploy the application. The config.yml is mounted into the container as a volume. By default the config.yml is expected to be located in the same directory as the docker-compose.yml but can be changed to another location if needed.

The DigitalOcean token can be specified in the config.yml or as an environment variable. If it's supplied in the config.yml just remove the environment part from the docker-comopose file.

To deploy copy the docker-compose.yml file from this repository (or clone the repository) and create a config.yml. Then run

docker-compose up -d

Helm chart

A helm chart for deploying the service within Kubernetes will be provided in the future.

do-dyndns's People

Contributors

dependabot[bot] avatar martinhell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

do-dyndns's Issues

Automatically add missing A records

Currently if the A record isn't manually created in digitalocean the application will ignore the record.

If the A record is missing it should automatically be created by the application

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.