Skip to content

Commit

Permalink
disable coredns in client mode or if 53 is in use
Browse files Browse the repository at this point in the history
  • Loading branch information
aptalca committed Oct 6, 2020
1 parent a64e45f commit b3703f2
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RUN \
jq \
libc6 \
libelf-dev \
net-tools \
openresolv \
perl \
pkg-config \
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RUN \
jq \
libc6 \
libelf-dev \
net-tools \
openresolv \
perl \
pkg-config \
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.armhf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RUN \
jq \
libc6 \
libelf-dev \
net-tools \
openresolv \
perl \
pkg-config \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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." }
Expand Down
15 changes: 6 additions & 9 deletions root/etc/cont-init.d/30-config
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 7 additions & 2 deletions root/etc/services.d/coredns/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@

cd /config/coredns

exec \
/app/coredns -dns.port=53
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

0 comments on commit b3703f2

Please sign in to comment.