From 9278f82e12ce9c27c08ec725d73c63422dbeeb1b Mon Sep 17 00:00:00 2001 From: MiguelNdeCarvalho Date: Thu, 1 Oct 2020 19:43:42 +0100 Subject: [PATCH 1/3] cont-init.d: Get the ip automatically silent --- root/etc/cont-init.d/30-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/etc/cont-init.d/30-config b/root/etc/cont-init.d/30-config index 4da95f8..b69ff5b 100644 --- a/root/etc/cont-init.d/30-config +++ b/root/etc/cont-init.d/30-config @@ -211,7 +211,7 @@ if [ -n "$PEERS" ]; then PEERS="1" fi if [ -z "$SERVERURL" ] || [ "$SERVERURL" = "auto" ]; then - SERVERURL=$(curl icanhazip.com) + SERVERURL=$(curl -s icanhazip.com) echo "**** SERVERURL var is either not set or is set to \"auto\", setting external IP to auto detected value of $SERVERURL ****" else echo "**** External server address is set to $SERVERURL ****" From 1a90c1af0e198c95f9afd2abbb9c78bf7e739efc Mon Sep 17 00:00:00 2001 From: aptalca Date: Tue, 6 Oct 2020 15:48:21 -0400 Subject: [PATCH 2/3] disable CoreDNS if host networking is detected --- README.md | 1 + readme-vars.yml | 1 + root/etc/cont-init.d/30-config | 11 ++++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ada4d36..bd95f92 100644 --- a/README.md +++ b/README.md @@ -291,6 +291,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **06.10.20:** - Disable CoreDNS when Host networking is detected. * **04.10.20:** - Allow to specify a list of names as PEERS and add ALLOWEDIPS environment variable. Also, add peer name/id to each one of the peer sections in wg0.conf. Important: Existing users need to delete `/config/templates/peer.conf` and restart * **27.09.20:** - Cleaning service binding example to have accurate PreDown script. * **06.08.20:** - Replace resolvconf with openresolv due to dns issues when a client based on this image is connected to a server also based on this image. Add IPv6 info to readme. Display kernel version in logs. diff --git a/readme-vars.yml b/readme-vars.yml index 181cfd3..d617bc9 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -103,6 +103,7 @@ app_setup_block: | # changelog changelogs: + - { date: "06.10.20:", desc: "Disable CoreDNS when Host networking is detected." } - { date: "04.10.20:", desc: "Allow to specify a list of names as PEERS and add ALLOWEDIPS environment variable. Also, add peer name/id to each one of the peer sections in wg0.conf. Important: Existing users need to delete `/config/templates/peer.conf` and restart" } - { date: "27.09.20:", desc: "Cleaning service binding example to have accurate PreDown script." } - { date: "06.08.20:", desc: "Replace resolvconf with openresolv due to dns issues when a client based on this image is connected to a server also based on this image. Add IPv6 info to readme. Display kernel version in logs." } diff --git a/root/etc/cont-init.d/30-config b/root/etc/cont-init.d/30-config index 300147f..f1bdebd 100644 --- a/root/etc/cont-init.d/30-config +++ b/root/etc/cont-init.d/30-config @@ -273,9 +273,14 @@ else fi fi -# set up CoreDNS -[[ ! -f /config/coredns/Corefile ]] && \ - cp /defaults/Corefile /config/coredns/Corefile +# set up or disable CoreDNS +if ip addr show dev docker0 > /dev/null 2>&1; then + echo "Host networking detected, disabling CoreDNS" + rm -rf /etc/services.d/coredns +else + [[ ! -f /config/coredns/Corefile ]] && \ + cp /defaults/Corefile /config/coredns/Corefile +fi # permissions chown -R abc:abc \ From b3703f24e239427d624d96dbed2556b96412ce48 Mon Sep 17 00:00:00 2001 From: aptalca Date: Tue, 6 Oct 2020 18:07:58 -0400 Subject: [PATCH 3/3] disable coredns in client mode or if 53 is in use --- Dockerfile | 1 + Dockerfile.aarch64 | 1 + Dockerfile.armhf | 1 + README.md | 2 +- readme-vars.yml | 2 +- root/etc/cont-init.d/30-config | 15 ++++++--------- root/etc/services.d/coredns/run | 9 +++++++-- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index eae63e1..4dadd32 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,7 @@ RUN \ jq \ libc6 \ libelf-dev \ + net-tools \ openresolv \ perl \ pkg-config \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index b47d5e5..f7363da 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -26,6 +26,7 @@ RUN \ jq \ libc6 \ libelf-dev \ + net-tools \ openresolv \ perl \ pkg-config \ diff --git a/Dockerfile.armhf b/Dockerfile.armhf index b8fde66..b4dc7bb 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -26,6 +26,7 @@ RUN \ jq \ libc6 \ libelf-dev \ + net-tools \ openresolv \ perl \ pkg-config \ diff --git a/README.md b/README.md index bd95f92..21ba6f8 100644 --- a/README.md +++ b/README.md @@ -291,7 +291,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions -* **06.10.20:** - Disable CoreDNS when Host networking is detected. +* **06.10.20:** - Disable CoreDNS in client mode, or if port 53 is already in use in server mode. * **04.10.20:** - Allow to specify a list of names as PEERS and add ALLOWEDIPS environment variable. Also, add peer name/id to each one of the peer sections in wg0.conf. Important: Existing users need to delete `/config/templates/peer.conf` and restart * **27.09.20:** - Cleaning service binding example to have accurate PreDown script. * **06.08.20:** - Replace resolvconf with openresolv due to dns issues when a client based on this image is connected to a server also based on this image. Add IPv6 info to readme. Display kernel version in logs. diff --git a/readme-vars.yml b/readme-vars.yml index d617bc9..113d121 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -103,7 +103,7 @@ app_setup_block: | # changelog changelogs: - - { date: "06.10.20:", desc: "Disable CoreDNS when Host networking is detected." } + - { date: "06.10.20:", desc: "Disable CoreDNS in client mode, or if port 53 is already in use in server mode." } - { date: "04.10.20:", desc: "Allow to specify a list of names as PEERS and add ALLOWEDIPS environment variable. Also, add peer name/id to each one of the peer sections in wg0.conf. Important: Existing users need to delete `/config/templates/peer.conf` and restart" } - { date: "27.09.20:", desc: "Cleaning service binding example to have accurate PreDown script." } - { date: "06.08.20:", desc: "Replace resolvconf with openresolv due to dns issues when a client based on this image is connected to a server also based on this image. Add IPv6 info to readme. Display kernel version in logs." } diff --git a/root/etc/cont-init.d/30-config b/root/etc/cont-init.d/30-config index 578938c..724d24b 100644 --- a/root/etc/cont-init.d/30-config +++ b/root/etc/cont-init.d/30-config @@ -266,22 +266,19 @@ if [ -n "$PEERS" ]; then fi fi else - echo "**** Client mode selected." + echo "**** Client mode selected. ****" if [ ! -f /config/wg0.conf ]; then echo "**** No client conf found. Provide your own client conf as \"/config/wg0.conf\" and restart the container. ****" sleep infinity fi -fi - -# set up or disable CoreDNS -if ip addr show dev docker0 > /dev/null 2>&1; then - echo "Host networking detected, disabling CoreDNS" + echo "**** Disabling CoreDNS ****" rm -rf /etc/services.d/coredns -else - [[ ! -f /config/coredns/Corefile ]] && \ - cp /defaults/Corefile /config/coredns/Corefile fi +# set up CoreDNS +[[ ! -f /config/coredns/Corefile ]] && \ + cp /defaults/Corefile /config/coredns/Corefile + # permissions chown -R abc:abc \ /config diff --git a/root/etc/services.d/coredns/run b/root/etc/services.d/coredns/run index f073c29..5448654 100644 --- a/root/etc/services.d/coredns/run +++ b/root/etc/services.d/coredns/run @@ -2,5 +2,10 @@ cd /config/coredns -exec \ - /app/coredns -dns.port=53 \ No newline at end of file +if netstat -apn | grep -q ":53 "; then + echo "Another service is using port 53, disabling CoreDNS" + sleep infinity +else + exec \ + /app/coredns -dns.port=53 +fi \ No newline at end of file