From c34d0b00a067c2c3573d4bd9aa57c5dae63f9357 Mon Sep 17 00:00:00 2001 From: p0lycarpio Date: Fri, 16 Jun 2023 14:35:59 +0200 Subject: [PATCH 01/10] add automatic ipv6 support --- readme-vars.yml | 2 ++ root/app/duck.sh | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/readme-vars.yml b/readme-vars.yml index e6933b3..13feb02 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -39,6 +39,8 @@ cap_add_param_vars: "" # optional container parameters opt_param_usage_include_env: true opt_param_env_vars: + - { env_var: "UPDATE_BOTH", env_value: "false", desc: "Set to `true` to update IPv4 and IPv6 address. NB: use only if you have a public IPv6 address."} + - { env_var: "FORCE_IPV6", env_value: "false", desc: "Set to `true` to update IP **only** with your public IPv6 address. NB: use only if you have a public IPv6 address."} - { 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: diff --git a/root/app/duck.sh b/root/app/duck.sh index 4605db4..6f11587 100755 --- a/root/app/duck.sh +++ b/root/app/duck.sh @@ -11,7 +11,17 @@ else fi { - RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=") + if [ "${UPDATE_BOTH}" = "true" ]; then + IPV4=$(curl -sS4 "https://ipconfig.io") + IPV6=$(curl -sS6 "https://ipconfig.io") + RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=${IPV4}&ipv6=${IPV6}") + elif [ "${FORCE_IPV6}" = "true" ]; then + IPV6=$(curl -sS6 "https://ipconfig.io") + RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=${IPV6}") + else + 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 From 4cacec78f1f26c2cd4b3c18f938cdc5dee216515 Mon Sep 17 00:00:00 2001 From: p0lycarpio Date: Mon, 17 Jul 2023 18:46:02 +0200 Subject: [PATCH 02/10] remove UPDATE_BOTH variable --- readme-vars.yml | 1 - root/app/duck.sh | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/readme-vars.yml b/readme-vars.yml index 13feb02..076b23b 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -39,7 +39,6 @@ cap_add_param_vars: "" # optional container parameters opt_param_usage_include_env: true opt_param_env_vars: - - { env_var: "UPDATE_BOTH", env_value: "false", desc: "Set to `true` to update IPv4 and IPv6 address. NB: use only if you have a public IPv6 address."} - { env_var: "FORCE_IPV6", env_value: "false", desc: "Set to `true` to update IP **only** with your public IPv6 address. NB: use only if you have a public IPv6 address."} - { 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 diff --git a/root/app/duck.sh b/root/app/duck.sh index 6f11587..ca1350c 100755 --- a/root/app/duck.sh +++ b/root/app/duck.sh @@ -11,11 +11,7 @@ else fi { - if [ "${UPDATE_BOTH}" = "true" ]; then - IPV4=$(curl -sS4 "https://ipconfig.io") - IPV6=$(curl -sS6 "https://ipconfig.io") - RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=${IPV4}&ipv6=${IPV6}") - elif [ "${FORCE_IPV6}" = "true" ]; then + if [ "${FORCE_IPV6}" = "true" ]; then IPV6=$(curl -sS6 "https://ipconfig.io") RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=${IPV6}") else From 9d3e78ed2ac00cc306795667735863d2f15ba01b Mon Sep 17 00:00:00 2001 From: p0lycarpio Date: Fri, 16 Jun 2023 14:35:59 +0200 Subject: [PATCH 03/10] merge variables --- Dockerfile | 2 ++ Dockerfile.aarch64 | 2 ++ readme-vars.yml | 2 +- root/app/duck.sh | 8 ++++++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 85738f4..9b3ec61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,8 @@ ARG DUCKDNS_VERSION LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="aptalca" +ENV UPDATE_IP=ipv4 + RUN \ echo "**** install packages ****" && \ apk add --no-cache \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index ef78e59..3622a28 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -9,6 +9,8 @@ ARG DUCKDNS_VERSION LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="aptalca" +ENV UPDATE_IP=ipv4 + RUN \ echo "**** install packages ****" && \ apk add --no-cache \ diff --git a/readme-vars.yml b/readme-vars.yml index 076b23b..fd82e21 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -39,7 +39,7 @@ cap_add_param_vars: "" # optional container parameters opt_param_usage_include_env: true opt_param_env_vars: - - { env_var: "FORCE_IPV6", env_value: "false", desc: "Set to `true` to update IP **only** with your public IPv6 address. NB: use only if you have a public IPv6 address."} + - { env_var: "UPDATE_IP", env_value: "ipv4", desc: "Set to `ipv6` to update **only** with your public IPv6 address. Set to `both` to update IPv6 and IPv4 address. Default to `ipv4`"} - { 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: diff --git a/root/app/duck.sh b/root/app/duck.sh index ca1350c..747c708 100755 --- a/root/app/duck.sh +++ b/root/app/duck.sh @@ -11,10 +11,14 @@ else fi { - if [ "${FORCE_IPV6}" = "true" ]; then + if [ "${UPDATE_IP}" = "both" ]; then + IPV4=$(curl -sS4 "https://ipconfig.io") + IPV6=$(curl -sS6 "https://ipconfig.io") + RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=${IPV4}&ipv6=${IPV6}") + elif [ "${UPDATE_IP}" = "ipv6" ]; then IPV6=$(curl -sS6 "https://ipconfig.io") RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=${IPV6}") - else + elif [ "${UPDATE_IP}" = "ipv4" ]; then RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=") fi From df80cf3118251bd31396a675ce60969575a4c5d3 Mon Sep 17 00:00:00 2001 From: p0lycarpio Date: Mon, 17 Jul 2023 22:06:41 +0200 Subject: [PATCH 04/10] fix default value --- Dockerfile | 2 -- Dockerfile.aarch64 | 2 -- root/app/duck.sh | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9b3ec61..85738f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,8 +9,6 @@ ARG DUCKDNS_VERSION LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="aptalca" -ENV UPDATE_IP=ipv4 - RUN \ echo "**** install packages ****" && \ apk add --no-cache \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 3622a28..ef78e59 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -9,8 +9,6 @@ ARG DUCKDNS_VERSION LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="aptalca" -ENV UPDATE_IP=ipv4 - RUN \ echo "**** install packages ****" && \ apk add --no-cache \ diff --git a/root/app/duck.sh b/root/app/duck.sh index 747c708..1257b43 100755 --- a/root/app/duck.sh +++ b/root/app/duck.sh @@ -18,7 +18,7 @@ fi elif [ "${UPDATE_IP}" = "ipv6" ]; then IPV6=$(curl -sS6 "https://ipconfig.io") RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=${IPV6}") - elif [ "${UPDATE_IP}" = "ipv4" ]; then + else RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=") fi From 1cf28dfba0e4366087b4ee512299fd3774600f25 Mon Sep 17 00:00:00 2001 From: p0lycarpio Date: Mon, 17 Jul 2023 22:54:42 +0200 Subject: [PATCH 05/10] update changelog --- readme-vars.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/readme-vars.yml b/readme-vars.yml index fd82e21..2390501 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -64,6 +64,7 @@ app_setup_block: | # changelog changelogs: + - { date: "17.07.23:", desc: "Add support for public IPv6 address update." } - { 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." } From fd3ec7eba57fa5c11d83424a987de93f97d37faf Mon Sep 17 00:00:00 2001 From: p0lycarpio Date: Fri, 13 Oct 2023 18:47:07 +0200 Subject: [PATCH 06/10] add dig to container and implement Cloudflare ip detection --- Dockerfile | 1 + Dockerfile.aarch64 | 1 + readme-vars.yml | 9 +++++++-- root/app/duck.sh | 15 ++++++++++----- 4 files changed, 19 insertions(+), 7 deletions(-) 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 2390501..e55f353 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -39,7 +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` to update **only** with your public IPv6 address. Set to `both` to update IPv6 and IPv4 address. Default to `ipv4`"} + - { env_var: "UPDATE_IP", env_value: "ipv4", desc: "Set to `ipv6` or `ipv4` to update **only** with your public IPv4/6 address. Set to `both` to update IPv6 and IPv4 address. This variable implies the [use of a third-party service](#notice-regarding-automatic-detection-of-public-ipv6-address)."} - { 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: @@ -62,9 +62,14 @@ app_setup_block: | - Create a container with your subdomain(s) and token - It will update your IP with the DuckDNS service every 5 minutes (with a random jitter) + ## Notice regarding automatic detection of public IPv6 address + + 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.** + # changelog changelogs: - - { date: "17.07.23:", desc: "Add support for public IPv6 address update." } + - { 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 1257b43..a99b50f 100755 --- a/root/app/duck.sh +++ b/root/app/duck.sh @@ -11,14 +11,19 @@ else fi { - if [ "${UPDATE_IP}" = "both" ]; then - IPV4=$(curl -sS4 "https://ipconfig.io") - IPV6=$(curl -sS6 "https://ipconfig.io") - RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=${IPV4}&ipv6=${IPV6}") + # Use cloudflare to autodetect IP if UPDATE_IP is set + if [ "${UPDATE_IP}" = "ipv4" ]; then + 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 - IPV6=$(curl -sS6 "https://ipconfig.io") + 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=${IPV6}") + elif [ "${UPDATE_IP}" = "both" ]; then + 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) RESPONSE=$(curl -sS --max-time 60 "https://www.duckdns.org/update?domains=${SUBDOMAINS}&token=${TOKEN}&ip=") fi From 8b9092a3e68c685ea09b66680fcf9c06ccc5616e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ars=C3=A8ne=20Reymond?= <66876397+p0lycarpio@users.noreply.github.com> Date: Sun, 15 Oct 2023 11:29:05 +0200 Subject: [PATCH 07/10] Update readme-vars.yml Co-authored-by: Eric Nemchik --- readme-vars.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme-vars.yml b/readme-vars.yml index e55f353..6f86e3e 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -39,7 +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** with your public IPv4/6 address. Set to `both` to update IPv6 and IPv4 address. This variable implies the [use of a third-party service](#notice-regarding-automatic-detection-of-public-ipv6-address)."} + - { 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."} - { 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: From 71e2a21c78a3e7c3916dd7c50957ee1b178a16d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ars=C3=A8ne=20Reymond?= <66876397+p0lycarpio@users.noreply.github.com> Date: Sun, 15 Oct 2023 11:29:12 +0200 Subject: [PATCH 08/10] Update readme-vars.yml Co-authored-by: Eric Nemchik --- readme-vars.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/readme-vars.yml b/readme-vars.yml index 6f86e3e..14d7d34 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -62,11 +62,13 @@ app_setup_block: | - Create a container with your subdomain(s) and token - It will update your IP with the DuckDNS service every 5 minutes (with a random jitter) - ## Notice regarding automatic detection of public IPv6 address + ## 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: "13.10.23:", desc: "Add support for public IPv6 address update using Cloudflare." } From 41042c5367f0b4aee81579b2cc185b8388a51e4e Mon Sep 17 00:00:00 2001 From: p0lycarpio Date: Thu, 19 Oct 2023 16:07:41 +0200 Subject: [PATCH 09/10] commit suggestions and pass `ipv6` param --- root/app/duck.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/root/app/duck.sh b/root/app/duck.sh index 9d4b6f6..ac1affc 100755 --- a/root/app/duck.sh +++ b/root/app/duck.sh @@ -13,17 +13,21 @@ fi { # 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}&ip=${IPV6}") + 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 From 3c96fe859936ce2783a7ac7416808f0280841bc3 Mon Sep 17 00:00:00 2001 From: p0lycarpio Date: Thu, 19 Oct 2023 23:13:46 +0200 Subject: [PATCH 10/10] add note about host networking --- readme-vars.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/readme-vars.yml b/readme-vars.yml index a63590a..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,7 +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."} + - { 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: