NextDNS with DNSMasq proxy - DNS filtering, privacy, and optional DHCP
2.2K
A lightweight Docker container combining NextDNS client with DNSMasq for DNS filtering, privacy, and optional DHCP server functionality.
amd64 and arm64docker run -d \
--name nextdns-dnsmasq \
-p 53:53/tcp \
-p 53:53/udp \
-e NEXTDNS_ID=your-config-id \
--cap-add NET_ADMIN \
--restart unless-stopped \
marcoamtz/nextdns-dnsmasq:latest
| Variable | Description | Default |
|---|---|---|
NEXTDNS_ID | Your NextDNS configuration ID | Required |
NEXTDNS_ARGUMENTS | Additional NextDNS CLI arguments | -listen :5053 -report-client-info -log-queries -cache-size 10MB |
LOG_DIR | Log directory path | /logs |
| Path | Description |
|---|---|
/logs | Service logs (NextDNS and DNSMasq) with automatic rotation |
/etc/dnsmasq.d | Custom DNSMasq configuration files |
/dhcp-leases | DHCP lease persistence (recommended for DHCP) |
| Port | Protocol | Description |
|---|---|---|
| 53 | TCP/UDP | DNS queries |
| 67 | UDP | DHCP server (optional) |
services:
nextdns-dnsmasq:
image: marcoamtz/nextdns-dnsmasq:latest
container_name: nextdns-dnsmasq
network_mode: host # Recommended for DNS/DHCP
environment:
- NEXTDNS_ID=your-config-id
- NEXTDNS_ARGUMENTS=-report-client-info -cache-size 10MB -log-queries
volumes:
- ./config:/etc/dnsmasq.d
- ./logs:/logs
- ./dhcp-leases:/dhcp-leases
cap_add:
- NET_ADMIN
restart: unless-stopped
Client → DNSMasq (port 53) → NextDNS (port 5053) → NextDNS Cloud
Mount a volume to /etc/dnsmasq.d with your DHCP configuration:
# /etc/dnsmasq.d/dhcp.conf
dhcp-range=192.168.1.50,192.168.1.150,12h
dhcp-option=option:router,192.168.1.1
dhcp-option=option:dns-server,192.168.1.1
Important: Mount /dhcp-leases to persist leases across container restarts.
# From host (with volume mounted)
tail -f ./logs/nextdns/current
tail -f ./logs/dnsmasq/current
# From inside container
docker exec nextdns-dnsmasq cat /logs/nextdns/current
Logs auto-rotate at 1MB, keeping 5 files (~5MB max per service).
Check current versions via Docker labels:
docker inspect --format='{{json .Config.Labels}}' nextdns-dnsmasq | jq
dnsmasq userContent type
Image
Digest
sha256:b7a814846…
Size
13 MB
Last updated
about 1 month ago
docker pull marcoamtz/nextdns-dnsmasq