Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/f-koehler/simple-docker-dns-server
Easily run a lightweight DNS server via docker-compose (e.g. for your LAN/VPN)
https://github.com/f-koehler/simple-docker-dns-server
dns dns-server dnsmasq docker docker-compose podman podman-compose
Last synced: 5 days ago
JSON representation
Easily run a lightweight DNS server via docker-compose (e.g. for your LAN/VPN)
- Host: GitHub
- URL: https://github.com/f-koehler/simple-docker-dns-server
- Owner: f-koehler
- License: mit
- Created: 2022-05-27T15:36:55.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-13T08:07:35.000Z (7 days ago)
- Last Synced: 2024-11-13T09:19:30.933Z (7 days ago)
- Topics: dns, dns-server, dnsmasq, docker, docker-compose, podman, podman-compose
- Language: Dockerfile
- Homepage:
- Size: 21.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Simple DNS server using docker-compose and dnsmasq
[![Docker Image](https://github.com/f-koehler/simple-docker-dns-server/actions/workflows/docker.yml/badge.svg)](https://github.com/f-koehler/simple-docker-dns-server/actions/workflows/docker.yml)
This repository showcases how you can easily set up a simple DNS server using `dnsmasq` and `docker-compose`/`docker`.
DNS entries can be added directly via the `docker-compose.yml` file, which can be easily automated (e.g. via ansible).Such a simple DNS server is ideal for internal use (e.g. at home or within a wireguard/tailscale VPN network).
## Option 1 - `docker-compose`
Change the DNS entries in the `extra_hosts` section in `docker-compose.yml`. The DNS server can be started by running
```bash
docker-compose up -d
```from the project directory.
By default, the DNS server will listen all IP addresses/interfaces (equivalent to `0.0.0.0`). This can be changed in the `ports` section by changing `53:53/tcp` to `:53:53/tcp` etc.
The server can be stopped by running
```bash
docker-compose down
```from the project directory.
`dnsmasq` can be configured by modifying the `dnsmasq.conf` file. After changing this file, it is necessary to first bring the server down and restart using the aforementioned commands.
## Option 2 - Plain `docker`
The server can be run with plain `docker` commands as well. First, the docker image is built using
```bash
docker build -t simple-docker-dns .
```and then started with
```bash
docker run -d --name dns_service \
--restart unless-stopped \
-v /etc/localtime:/etc/localtime:ro \
-v $(pwd)/dnsmasq.conf:/etc/dnsmasq.conf:ro \
-p 53:53/tcp \
-p 53:53/udp \
--add-host foo.bar:192.168.0.1 \
simple-docker-dns
```The DNS entries are specified using `--add-host `.
The server can subequently be stopped using
```bash
docker stop simple-docker-dns
````dnsmasq` can be configured by modifying the `dnsmasq.conf` file. After changing this file, it is necessary to first bring the server down, rebuild the docker image and finally start it again.