diff --git a/Dockerfile b/Dockerfile index 85738f4..c90f502 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,7 @@ LABEL maintainer="aptalca" RUN \ echo "**** install packages ****" && \ apk add --no-cache \ + bind-tools \ logrotate # add local files diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index ef78e59..99187d0 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -12,6 +12,7 @@ LABEL maintainer="aptalca" RUN \ echo "**** install packages ****" && \ apk add --no-cache \ + bind-tools \ logrotate # add local files diff --git a/readme-vars.yml b/readme-vars.yml index 666c92b..9231264 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -19,9 +19,9 @@ development_versions_items: "" # container parameters common_param_env_vars_enabled: 'optional' #PGID, PUID, etc, you can set it to 'optional' param_container_name: "{{ project_name }}" -param_usage_include_net: false #you can set it to 'optional' -param_net: "" -param_net_desc: "" +param_usage_include_net: 'optional' #you can set it to 'optional' +param_net: "host" +param_net_desc: "Use host networking for IPv6 detection" param_usage_include_env: true param_env_vars: - { env_var: "TZ", env_value: "Europe/London", desc: "Specify a timezone to use EG Europe/London"} @@ -39,6 +39,7 @@ cap_add_param_vars: "" # optional container parameters opt_param_usage_include_env: true opt_param_env_vars: + - { env_var: "UPDATE_IP", env_value: "ipv4", desc: "Set to `ipv6` or `ipv4` to update **only** your public IPv4/6 address. Set to `both` to update IPv6 and IPv4 address. This variable makes use of a [third-party service](#notice-regarding-automatic-detection). Omitting this variable uses DuckDNS for detection and only supports IPv4. `both` and `ipv6` modes needs [host networking](#networking-net)."} - { env_var: "LOG_FILE", env_value: "false", desc: "Set to `true` to log to file (also need to map /config)."} opt_param_usage_include_vols: true opt_param_volumes: @@ -61,9 +62,17 @@ app_setup_block: | - Create a container with your subdomain(s) and token. If you own user.duckdns.org, you put `SUBDOMAINS=user` you would NOT put a sub subdomain like overseerr from overseerr.user.ducksdns.org - It will update your IP with the DuckDNS service every 5 minutes (with a random jitter) + ## Notice regarding automatic detection + + Using the `UPDATE_IP` variable whatever its value (`ipv4`, `ipv6` or `both`) uses external *Cloudflare whoami* service to detect public IP addresses. + **Be aware that using this variable will query a third-party service other than DuckDNS.** + + Omitting the `UPDATE_IP` variable uses DuckDNS for detection and only supports IPv4. + # changelog changelogs: - { date: "14.10.23:", desc: "Rework shell script for case insensitivity and update readme to be more clear." } + - { date: "13.10.23:", desc: "Add support for public IPv6 address update using Cloudflare." } - { date: "25.05.23:", desc: "Rebase to Alpine 3.18, deprecate armhf." } - { date: "02.03.23:", desc: "Rework shell scripts and cron logic." } - { date: "13.02.23:", desc: "Rebase to alpine 3.17." } diff --git a/root/app/duck.sh b/root/app/duck.sh index c48f09f..ac1affc 100755 --- a/root/app/duck.sh +++ b/root/app/duck.sh @@ -11,7 +11,26 @@ else fi { - RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=") + # Use cloudflare to autodetect IP if UPDATE_IP is set + if [ "${UPDATE_IP}" = "ipv4" ]; then + echo "Detecting IPv4 via CloudFlare" + IPV4=$(dig +short ch txt whoami.cloudflare -4 @1.1.1.1 | sed 's/"//g') + RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=${IPV4}") + elif [ "${UPDATE_IP}" = "ipv6" ]; then + echo "Detecting IPv6 via CloudFlare" + IPV6=$(dig +short ch txt whoami.cloudflare -6 @2606:4700:4700::1111 | sed 's/"//g') + RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ipv6=${IPV6}") + elif [ "${UPDATE_IP}" = "both" ]; then + echo "Detecting IPv4 and IPv6 via CloudFlare" + IPV4=$(dig +short ch txt whoami.cloudflare -4 @1.1.1.1 | sed 's/"//g') + IPV6=$(dig +short ch txt whoami.cloudflare -6 @2606:4700:4700::1111 | sed 's/"//g') + RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=${IPV4}&ipv6=${IPV6}") + else + # Use DuckDns to autodetect IPv4 (default behaviour) + echo "Detecting IPv4 via DuckDNS" + RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=") + fi + if [ "${RESPONSE}" = "OK" ]; then echo "Your IP was updated at $(date)" else