Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates and Optimizations #38

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions Dockerfile

This file was deleted.

35 changes: 3 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,10 @@ dnsmasq in a docker container, configurable via a [simple web UI](https://github

### Usage

1. Create a [`/opt/dnsmasq.conf`](http://oss.segetech.com/intra/srv/dnsmasq.conf) file on the Docker host

```ini
#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
#serve all .company queries using a specific nameserver
server=/company/10.0.0.1
#explicitly define host-ip mappings
address=/myhost.company/10.0.0.2
```

1. Run the container

```
$ docker run \
--name dnsmasq \
-d \
-p 53:53/udp \
-p 5380:8080 \
-v /opt/dnsmasq.conf:/etc/dnsmasq.conf \
--log-opt "max-size=100m" \
-e "HTTP_USER=foo" \
-e "HTTP_PASS=bar" \
--restart always \
jpillora/dnsmasq
```bash
/Docker-Dnsmasq/bash $ sh up.sh
```

1. Visit `http://<docker-host>:5380`, authenticate with `foo/bar` and you should see
Expand All @@ -48,7 +19,7 @@ dnsmasq in a docker container, configurable via a [simple web UI](https://github

1. Test it out with

```
```bash
$ host myhost.company <docker-host>
Using domain server:
Name: <docker-host>
Expand Down
3 changes: 3 additions & 0 deletions bash/down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker compose -f ../compose.yaml down
3 changes: 3 additions & 0 deletions bash/up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker compose -f ../compose.yaml up -d
18 changes: 18 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: dnsmasq
services:
dnsmasq:
image: jpillora/dnsmasq
build:
context: .
dockerfile: ./docker/Dockerfile
container_name: dnsmasq
environment:
- HTTP_USER=foo
- HTTP_PASS=bar
volumes:
- ./conf/dnsmasq.conf:/etc/dnsmasq.conf
- ./conf/dnsmasq.hosts:/etc/dnsmasq.hosts
ports:
- 53:53/udp
- 5380:8080
restart: always
22 changes: 22 additions & 0 deletions conf/dnsmasq.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# dnsmasq config, for a complete example, see:
# http://oss.segetech.com/intra/srv/dnsmasq.conf

# Set the size of dnsmasq's cache.
cache-size=0

#log all dns queries
#log-queries

# Don't read the hostnames in /etc/hosts.
no-hosts
addn-hosts=/etc/dnsmasq.hosts

# Specify upstream servers directly.
no-resolv
clear-on-reload
server=1.2.4.8
server=114.114.114.114
# Specify queries using a specific nameserver
#server=/*.cn/1.2.4.8
# *.lan is local domain
local=/*.lan/
5 changes: 5 additions & 0 deletions conf/dnsmasq.hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Specify an IP address to return for any host in the given domains.
# lan
192.168.1.1 route.lan
192.168.1.250 ac.lan
192.168.1.60 pro.pve.lan
14 changes: 0 additions & 14 deletions dnsmasq.conf

This file was deleted.

17 changes: 17 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM alpine:3.21
LABEL maintainer="[email protected]"
# setup dnsmasq and webproc binary
ENV WEBPROC_URL https://github.com/jpillora/webproc/releases/download/v0.4.0/webproc_0.4.0_linux_amd64.gz
RUN apk update \
&& apk --no-cache add dnsmasq \
&& apk add --no-cache --virtual .build-deps curl \
&& curl -sL $WEBPROC_URL | gzip -d - > /usr/local/bin/webproc \
&& chmod +x /usr/local/bin/webproc \
&& apk del .build-deps
# configure dnsmasq
RUN mkdir -p /etc/default/ \
&& echo -e "ENABLED=1\nIGNORE_RESOLVCONF=yes" > /etc/default/dnsmasq
COPY ../conf/dnsmasq.conf /etc/dnsmasq.conf
COPY ../conf/dnsmasq.hosts /etc/ndsmasq.hosts
#run!
ENTRYPOINT ["webproc","-c","/etc/dnsmasq.conf","-c","/etc/dnsmasq.hosts","--","dnsmasq","--no-daemon"]