-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dnsmasq as an optional container
- Loading branch information
Showing
8 changed files
with
162 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
cd $DIR | ||
docker build -t liip/pontsun-dnsmasq:latest dnsmasq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM alpine:edge | ||
|
||
RUN apk --no-cache add dnsmasq | ||
|
||
ADD dnsmasq.conf /etc/ | ||
|
||
EXPOSE 53 53/udp | ||
ENTRYPOINT ["dnsmasq", "-d"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#dnsmasq config, for a complete example, see: | ||
# http://oss.segetech.com/intra/srv/dnsmasq.conf | ||
#log all dns queries | ||
log-queries | ||
#dont use hosts nameservers | ||
no-resolv | ||
#use cloudflare as default nameservers, prefer 1^4 | ||
server=1.0.0.1 | ||
server=1.1.1.1 | ||
strict-order | ||
conf-dir=/etc/dnsmasq.d/,*.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: '3.5' | ||
services: | ||
dns: | ||
image: liip/pontsun-dnsmasq:latest | ||
container_name: pontsun_dns | ||
restart: always | ||
volumes: | ||
- "$PONTSUN_DIR_ETC/dnsmasq.d/:/etc/dnsmasq.d/" | ||
ports: | ||
- 53:53/udp | ||
networks: | ||
- pontsun | ||
logging: | ||
options: | ||
max-size: 20m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
PONTSUN_DNS=$(docker inspect -f '{{.State.Running}}' pontsun_dns 2> /dev/null || echo 'false') | ||
|
||
if [[ $PONTSUN_DNS == 'true' ]]; then | ||
DOCKER_COMPOSE="docker-compose -f docker-compose.yml -f docker-compose.dns.yml" | ||
cd $DIR/../containers/ | ||
if $DOCKER_COMPOSE exec dns ash -c "if [[ -f /etc/dnsmasq.d/$1.conf ]]; then exit 1; fi; echo address=/$1/127.0.0.1 > /etc/dnsmasq.d/$1.conf" | ||
then | ||
$DOCKER_COMPOSE restart dns | ||
fi | ||
else | ||
# no DNS container. | ||
# write it to system dnsmasq | ||
|
||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
ETC_PREFIX=$(brew --prefix)'/etc' | ||
else | ||
ETC_PREFIX='/etc' | ||
fi | ||
|
||
if [[ ! -d $ETC_PREFIX/dnsmasq.d/ ]]; then | ||
RED='\033[0;31m' | ||
NC='\033[0m' # No Color | ||
|
||
printf "${RED}pontsun_dns is not running and can't find $ETC_PREFIX/dnsmasq.d${NC}\n" | ||
printf "Please install dnsmasq locally or start potsun_dns" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -f $ETC_PREFIX/dnsmasq.d/$1.conf ]]; then | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
echo address=/$1/127.0.0.1 > $ETC_PREFIX/dnsmasq.d/$1.conf | ||
echo 'strict-order' >> $ETC_PREFIX/dnsmasq.d/$1.conf | ||
else | ||
echo address=/$1/127.0.0.1 | sudo tee $ETC_PREFIX/dnsmasq.d/$1.conf | ||
echo 'strict-order' | sudo tee --append $ETC_PREFIX/dnsmasq.d/$1.conf | ||
fi | ||
echo "dnsmasq entry updated, you may restart it to take effect." | ||
else | ||
echo "No dnsmasq changes done, $ETC_PREFIX/dnsmasq.d/$1.conf already exists." | ||
fi | ||
fi | ||
|
||
if [[ "$OSTYPE" == "darwin"* ]] && [[ ! -f /etc/resolver/$1 ]]; then | ||
echo "Adding to /etc/resolver/$1" | ||
sudo mkdir -vp /etc/resolver | ||
sudo bash -c "echo 'nameserver 127.0.0.1' > /etc/resolver/$1" | ||
fi |