https://github.com/mietzen/caddy-dynamicdns-cmd-source
Command IP source for caddy-dynamicdns
https://github.com/mietzen/caddy-dynamicdns-cmd-source
caddy caddy-module caddy2 cmdline command-line ddns dyndns
Last synced: 2 months ago
JSON representation
Command IP source for caddy-dynamicdns
- Host: GitHub
- URL: https://github.com/mietzen/caddy-dynamicdns-cmd-source
- Owner: mietzen
- License: mit
- Created: 2023-04-18T07:43:50.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-17T04:47:38.000Z (6 months ago)
- Last Synced: 2025-01-23T12:15:43.352Z (4 months ago)
- Topics: caddy, caddy-module, caddy2, cmdline, command-line, ddns, dyndns
- Language: Go
- Homepage:
- Size: 56.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Command IP source module for [caddy-dynamicdns](https://github.com/mholt/caddy-dynamicdns)
=========================This is a IP source for [caddy-dynamicdns](https://github.com/mholt/caddy-dynamicdns). You can use it to get your IP via any command line script or program.
E.g. get your IP from your Fritz!BOX Router via this command:
```Shell
curl -s -H 'Content-Type: text/xml; charset="utf-8"' \
-H 'SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress' \
-d ' ' \
"http://$FRITZ_BOX_HOSTNAME:49000/igdupnp/control/WANIPConn1" | \
grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'
```
[Source](https://github.com/ddclient/ddclient/blob/4458cceb1b29b4b85fbe4f38f3381a6621048d00/sample-get-ip-from-fritzbox)## Install
You "install" this module by building your own `caddy` binary via `xcaddy`.
Example for [Cloudflare DNS](https://github.com/caddy-dns/cloudflare):
```Shell
xcaddy build --with github.com/mholt/caddy-dynamicdns --with github.com/mietzen/caddy-dynamicdns-cmd-source --with github.com/caddy-dns/cloudflare
```## Config
Here's an example on how to run a custom command to get the IP addresses. If the command returns ipv4 and ipv6 addresses, make sure that they are comma separated.
Caddyfile config ([global options](https://caddyserver.com/docs/caddyfile/options)):
```
{
dynamic_dns {
provider cloudflare {env.CLOUDFLARE_API_TOKEN}
domains {
example.net subdomain
}
ip_sources command echo 1.2.3.4,2004:1234::1234
check_interval 5m
ttl 1h
}
}
```Equivalent JSON config:
```jsonc
{
"apps": {
"dynamic_dns": {
"dns_provider": {
"name": "cloudflare",
"api_token": "{env.CLOUDFLARE_API_TOKEN}"
},
"domains": {
"example.net": ["subdomain"]
},
"ip_sources": [
{
"source": "command",
"command": "echo",
"args": ["1.2.3.4,2004:1234::1234"]
}
],
"check_interval": "5m",
"versions": {
"ipv4": true,
"ipv6": true
},
"ttl": "1h",
"dynamic_domains": false
}
}
}
```