This is a simple DynDNS server that updates a Google Cloud DNS record with the client's IP address. It is designed to be run as a small docker container on a server that has a static IP address.
- Clone this repository
- Build the docker image:
docker build -t dyndns:latest .
- Show the help:
docker run --rm dyndns:latest --help
Usage of /dyndns.bin:
-auth string
Basic Auth username:password
-auth-file string
Path to file containing the Google Cloud credentials (default "google.json")
-bind-address string
Bind address for the server (default ":8080")
-dns-zone-name string
DNS zone name
-domain-name string
Domain name
-project-id string
Google Cloud project ID
- Create a Google Cloud service account and download the JSON key file. It needs read/write permission for the DNS zone you want to update.
Parameter | Description | Required |
---|---|---|
auth | Basic Auth username:password. Use format username:password |
No - default env:DYNDNS_AUTH |
auth-file | Path to the Google Cloud credentials file | No - default env:DYNDNS_AUTH_FILE => fallback to: google.json |
bind-address | Bind address for the server. Use format ip:port |
No - default :8080 |
dns-zone-name | DNS zone name from Cloud DNS | Yes - default: env:DYNDNS_DNS_ZONE_NAME |
domain-name | Domain name to update including the subdomain. For example home.mydomain.tld |
Yes - default: env:DYNDNS_DOMAIN_NAME |
project-id | Google Cloud project ID | Yes - default: env:DYNDNS_PROJECT_ID |
When using docker you should not change the --bind-address
flag. The container will only expose port 8080.
You can load the auth-file
from an env variable. Todo this set --auth-file
to env://YOUR_ENV_VAR_NAME
and
set YOUR_ENV_VAR_NAME
to the content of the file.
docker run -d --name dyndns \
-p 8080:8080 \
-v /path/to/google.json:/google.json \
dyndns:latest \
-auth username:password \
-dns-zone-name my-dns-zone \
-domain-name home.mydomain.tld \
-project-id my-google-project
This server supports updates of IPv4 and IPv6 addresses. The client can send a GET
request to the server.
GET https://my-dyndns-server.lan/dyn?ip_address=IP_V4_ADDRESS&ipv6_address=IP_V6_ADDRESS
The server will validate the provided IP addresses and create/update the DNS records if they are valid.
{
"name": "home.mydomain.tld.",
"v4": {
"rr_type": "A",
"success": true,
"created": false,
"updated": true,
"value": "20.15.79.10"
},
"v6": {
"rr_type": "AAAA",
"success": true,
"created": false,
"updated": true,
"value": "2a05:3100:0000:572:cafe:f00a:af39:beef"
}
}
If validation fails or the record could not be updated, the response will contain an error message.
You can only use public routable IP addresses. The server will not accept private or otherwise reserved IP addresses.
You can also run the server without docker. You need to have Go installed on your system.
-
Clone this repository
-
Build the server:
- Linux/Mac:
go build -o dyndns.bin cmd/server/main.go
- Windows:
go build -o dyndns.exe cmd/server/main.go
- Linux/Mac:
Run the
server: ./dyndns.(bin|exe) --bind-address="localhost:3000" --auth username:password --dns-zone-name my-dns-zone --domain-name home.mydomain.tld --project-id my-google-project
This will start the server on localhost:3000
with basic auth and the provided Google Cloud credentials.
You can use the provided dyndns-client
to update the DNS record. It is a simple Go program that sends a GET
request
to the server.
-
Clone this repository
-
Build the client:
- Linux/Mac:
go build -o dyndns-client.bin cmd/client/main.go
- Windows:
go build -o dyndns-client.exe cmd/client/main.go
- Linux/Mac:
./dyndns-client.(bin|exe) -- --server-url="https://my-dyndns-server.lan" --username=username --password=password --ip-provider=icanhazipcom
./dyndns-client.(bin|exe) --list-providers