{"id":15562388,"url":"https://github.com/longsleep/mydyns","last_synced_at":"2025-04-23T23:11:32.544Z","repository":{"id":31943181,"uuid":"35512880","full_name":"longsleep/mydyns","owner":"longsleep","description":"Mydyns implements a HTTP API to update a dynamic DNS zone","archived":false,"fork":false,"pushed_at":"2024-04-22T14:21:00.000Z","size":56,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-23T23:11:28.493Z","etag":null,"topics":["dynamic-dns","hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/longsleep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-12T21:10:40.000Z","updated_at":"2024-04-22T14:21:04.000Z","dependencies_parsed_at":"2024-06-21T18:09:07.882Z","dependency_job_id":null,"html_url":"https://github.com/longsleep/mydyns","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longsleep%2Fmydyns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longsleep%2Fmydyns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longsleep%2Fmydyns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longsleep%2Fmydyns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/longsleep","download_url":"https://codeload.github.com/longsleep/mydyns/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250528868,"owners_count":21445517,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamic-dns","hacktoberfest"],"created_at":"2024-10-02T16:14:01.255Z","updated_at":"2025-04-23T23:11:32.523Z","avatar_url":"https://github.com/longsleep.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Mydyns\n==========\n\nMydyns implements a HTTP API to update a dynamic DNS zone by adding or\nremoving A and AAAA records from a DNS zone. Mydyns uses the `nsupdate`\nutility to submit Dynamic DNS Update requests as defined in RFC 2136 to a name\nserver.\n\n## Build requirements\n\n  - [Go](http://golang.org) \u003e= 1.13\n\n\n## Runtime requirements\n\n  - nsupdate (Found in dnsutils provided with BIND)\n\n\n## Building\n\n```bash\n$ make\n```\n\n## Configuration of users and hosts\n\nMydyns requires a users database and a hosts database. Both are simple text\nfiles.\n\n### Users database users.db\n\nThe users database can be managed with `htpasswd` from Apache. Make sure to use\nSHA for password hashing.\n\n```bash\n$ htpasswd -c -s users.db myuser\n```\n\n### Hosts database hosts.db\n\nThe hosts database is a simple text file listing one host per line. In\naddition, the hosts have to be mapped to users. Users are added after the host,\nfollowed by a colon. Multiple users should be comma-separated.\n\n```\nsomehost:usera,userb\notherhost:userc\n```\n\n### Security database security.db\n\nThe security database is a simple text file listing one user with the current\nsecurity code for this user. The entry is optional. The security code can\nbe used to expire all existing tokens for this user. Tokens must always have\nthe current security code, else they are not valid and useless. Change or set\nthe security code, if a token becomes stolen. All tokens of a single user use\nthe same security code.\n\n```\nusera:current security code\nuserb:supercode\n```\n\n## DNS configuration and key\n\nMydyns sends updates to an upstream Bind DNS server using the `nsupdate` utility\nto send Dynamic DNS Update requests to a name server. This requires authentication,\nso you need to generate a DNSSec key which is used to connect to the DNS server\nand allows the update.\n\n```bash\n$ dnssec-keygen -a HMAC-SHA256 -b 256 -n HOST your.dns.zone\n```\n\nThis creates a public and private key. Add the public key to allow updates\nto your DNS zone, and use the private key file when starting `mydynsd`.\n\n\n## Tokens\n\nMydyns uses tokens to authenticate `/update` requests for hosts. The token\ncontains a HMAC of the user and the host. The secret for creating the HMAC\nis read from a file passed via the `--secret` parameter. You shoud generate\nthe file with some random data.\n\n```bash\n$ dd if=/dev/urandom of=secret.key bs=1 count=32\n```\n\nThe length of the key should be 32 or 64 bytes.\n\n\n## Startup\n\n```bash\n$ ./mydynsd \\\n\t--server=your.name.server \\\n\t--key=dnssec.key.private \\\n\t--zone=your.dns.zone \\\n\t--users=users.db \\\n\t--hosts=hosts.db \\\n\t--security=security.db \\\n\t--secret=secret.key \\\n\t--listen=127.0.0.1:8040 \\\n\t--ttl=60\n```\n\nWhile the server is running, you can send the HUP signal to make it reload the\ndatabase files for users, hosts and security. All other changes require a full\nrestart.\n\n## HTTP API\n\nThe server provides HTTP API endpoints.\n\n### /token\n\nThe first one is `/token` which is used to generate an update token for a host.\nThe `/token` endpoint requires HTTP Basic authentication to provide the user and\npassword. When successfully authenticated and the user is listed in the hosts\ndatabase for the provides hostname, the token is returned. This token value can\nthen be used to use `/update` for that hostname.\n\n```bash\n$ curl -u user:password https://yourserver/token?hostname=myhost\n```\n\n### /update\n\nTo send an update request, use the `/update` endpoint with the `token` parameter.\nWhen no further parameters are passed, it will set the IP address where the\nrequest came from for the hostname encoded in the token. You can also pass\nthe IP address manually with the `myip` parameter. For compatibility reasons,\nthe value `auto` and the `address` parameter are also supported. To only\nreturn the current IP without changing anything, pass the `check` parameter.\n\n```bash\n$ curl https://yourserver/update?token=tokenvalue\n```\n\nThere is an update script example in the `scripts` directory which you can\nuse to run from cron or similar. Also check the `extra` directory for some\nideas on how to run the daemon as an upstart service.\n\n\n## Expose service to the Internet\n\nMydyns runs on the local interface by default. If you want to expose the\nservice to the public Internet, you should run it behind a transparent proxy\nlike Nginx to provide TLS encryption. For auto-detection of the remote IP\naddresses to work, make sure that the proxy injects the remote IP address in\nthe `X-Real-IP` HTTP request header.\n\n### Nginx example\n\n```\nlocation ~* /(token|update)$ {\n\tproxy_pass http://127.0.0.1:8040;\n\tproxy_set_header Host $http_host;\n\tproxy_set_header X-Real-IP $remote_addr;\n}\n```\n\n## Docker\n\nThe Dockerfile can be used to build a Docker images to run `mydynsd` in a\ncontainer.\n\n### Building Docker container\n\nRunning this will build you a minimal Docker image including the nsupdate\nutility. As the image is minimal, it is using a static build of `mydynsd` to\navoid system dependencies.\n\n```bash\n$ sudo docker build -t longsleep/mydynsd -f Dockerfile .\n```\n\n### Running Docker container\n\nRunning it for the first time will set up the location of the configuration and the\nport of your choice. Make sure to put all the configuration files and keys into\na single folder and mount this folder as `/data` into Docker. Pass all the parameters\nto your files relatively to the /data directory of the container. Create all the files\nbefore running the container for the first time.\n\n```bash\n$ sudo docker run --rm=true -p=127.0.0.1:8040:8040 -v=/mnt/mydyns:/data --sig-proxy=true -it longsleep/mydynsd /app/mydynsd --server=your.name.server --key=/data/dnssec.key.private --zone=your.dns.zone --users=/data/users.db --hosts=/data/hosts.db --security=/data/security.db --secret=/data/secret.key --listen=0.0.0.0:8040 --ttl=60 --log=/data/mydynsd.log\n```\n\nThis runs a Mydyns in a temporary container in foreground. To stop it,\njust press CTRL+C. To run the container as a system service, check out the\nupstart example in `extras/mydynsd-container.upstart`. When running properly\nwith upstart, doing a `reload mydynsd-container` will reload the databases,\nwithout interrupting the service.\n\n\n--\nSimon Eisenmann - mailto:simon@longsleep.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flongsleep%2Fmydyns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flongsleep%2Fmydyns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flongsleep%2Fmydyns/lists"}