From c9cc82890761673116b9043e40322de7d0337296 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Sat, 29 Jul 2023 14:39:37 -0700 Subject: [PATCH] `dnsmasq` container is testing successfully now. --- Config/DNS/Dockerfile | 23 ++++++++++++++--------- Config/DNS/config/resolv.conf.example | 4 ++-- Config/DNS/docker-compose.yml | 13 +++---------- Config/DNS/run.sh | 4 +++- Config/DNS/undo.sh | 4 +++- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Config/DNS/Dockerfile b/Config/DNS/Dockerfile index 2b6879d..e81763e 100644 --- a/Config/DNS/Dockerfile +++ b/Config/DNS/Dockerfile @@ -2,20 +2,25 @@ # # Create a Debian container which runs dnsmasq. # https://wiki.debian.org/dnsmasq +# https://computingforgeeks.com/run-and-use-dnsmasq-in-docker-container/?expand_article=1 # FROM debian -# Remove Existing Config -RUN rm -rfv /etc/{hosts,resolv.conf,dnsmasq.conf} - # Install Dependencies -RUN apt update && apt install -y dnsmasq +RUN apt-get update && apt-get install -y dnsmasq vim inetutils-ping # Copy Configuration Files -COPY ./config/hosts /etc/ -COPY ./config/resolv.conf /etc/ -COPY ./config/dnsmasq.conf /etc/ +RUN mkdir -pv /etc/dnsmasq +COPY ./config/hosts /etc/dnsmasq/hosts +COPY ./config/resolv.conf /etc/dnsmasq/resolv.conf +COPY ./config/dnsmasq.conf /etc/dnsmasq/dnsmasq.conf -## Reload Service -RUN service dnsmasq restart +# Stop Default Service +RUN service dnsmasq stop + +# Load Specific Config Files +CMD dnsmasq -k --log-facility=- --log-queries=extra \ + --conf-file=/etc/dnsmasq/dnsmasq.conf \ + --no-hosts --addn-hosts=/etc/dnsmasq/hosts \ + --resolv-file=/etc/dnsmasq/resolv.conf diff --git a/Config/DNS/config/resolv.conf.example b/Config/DNS/config/resolv.conf.example index 039a181..fbb6715 100644 --- a/Config/DNS/config/resolv.conf.example +++ b/Config/DNS/config/resolv.conf.example @@ -10,11 +10,11 @@ # The local domains being hosted. search example.com anotherdomain.com -# Explicitly set local caching with /etc/hosts on. +# Explicitly set local caching with hosts file on. nameserver 127.0.0.1 # Add any extra settings. -options rotate +#options rotate # Use Cloudflare for upstream DNS. nameserver 1.1.1.1 diff --git a/Config/DNS/docker-compose.yml b/Config/DNS/docker-compose.yml index f30ea37..7ea02c7 100644 --- a/Config/DNS/docker-compose.yml +++ b/Config/DNS/docker-compose.yml @@ -10,14 +10,7 @@ version: '3' services: app: build: ./ - restart: on-failure + restart: always ports: - - "53:53" - command: | - /bin/sh -c ' - while : - do - sleep 8h & wait $${!} - service dnsmasq restart - done - ' + - "53:53/udp" + - "53:53/tcp" diff --git a/Config/DNS/run.sh b/Config/DNS/run.sh index 338d724..3b05686 100755 --- a/Config/DNS/run.sh +++ b/Config/DNS/run.sh @@ -1,3 +1,5 @@ +#!/bin/bash +# # 2023-07-29 # Config/DNS/run.sh # Fix common issues when trying to run this container. @@ -16,7 +18,7 @@ function stop-service { fi systemctl disable --now $service && echo "$service stopped successfully!" || - echo "$service was not found, no problem." + echo "* If $service was not found then there is no problem." } echo -e "\n*** Turn off any local DNS programs ***" diff --git a/Config/DNS/undo.sh b/Config/DNS/undo.sh index d922e1a..12612c5 100755 --- a/Config/DNS/undo.sh +++ b/Config/DNS/undo.sh @@ -1,3 +1,5 @@ +#!/bin/bash +# # 2023-07-29 # Config/DNS/undo.sh # Easy way to stop using this container. @@ -16,7 +18,7 @@ function start-service { fi systemctl enable --now $service && echo "$service started successfully!" || - echo "$service was not found, no problem." + echo "* If $service was not found then there is no problem." } echo -e "\n*** Stop the docker container ***"