• Stars
    star
    401
  • Rank 104,198 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created over 8 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿฌ Lightweight caching DNS server/forwarder

go-dnsmasq

Latest Version Github All Releases Docker Pulls License

go-dnsmasq is a lightweight (1.2 MB) DNS caching server/forwarder with minimal filesystem and runtime overhead.

Application examples:

  • Caching DNS server/forwarder in a local network
  • Container/Host DNS cache
  • DNS proxy providing DNS search capabilities to musl-libc based clients, particularly Alpine Linux

Features

  • Automatically set upstream nameservers and search domains from resolv.conf
  • Insert itself into the host's /etc/resolv.conf on start
  • Serve static A/AAAA records from a hosts file
  • Provide DNS response caching
  • Replicate the search domain treatment not supported by musl-libc based Linux distributions
  • Supports virtually unlimited number of search paths and nameservers (related Kubernetes article)
  • Configure stubzones (different nameserver for specific domains)
  • Round-robin of DNS records
  • Send server metrics to Graphite and StatHat
  • Configuration through both command line flags and environment variables

Resolve logic

DNS queries are resolved in the style of the GNU libc resolver:

  • The first nameserver (as listed in resolv.conf or configured by --nameservers) is always queried first, additional servers are considered fallbacks
  • Multiple search domains are tried in the order they are configured.
  • Single-label queries (e.g.: "redis-service") are always qualified with the search domains
  • Multi-label queries (ndots >= 1) are first tried as absolute names before qualifying them with the search domains

Command-line options / environment variables

Flag Description Default Environment vars
--listen, -l Address to listen on host[:port] 127.0.0.1:53 $DNSMASQ_LISTEN
--default-resolver, -d Update resolv.conf to make go-dnsmasq the host's nameserver False $DNSMASQ_DEFAULT
--nameservers, -n Comma delimited list of nameservers host[:port]. IPv6 literal address must be enclosed in brackets. (supersedes etc/resolv.conf) - $DNSMASQ_SERVERS
--stubzones, -z Use different nameservers for given domains. Can be passed multiple times. domain[,domain]/host[:port][,host[:port]] - $DNSMASQ_STUB
--hostsfile, -f Path to a hosts file (e.g. โ€˜/etc/hostsโ€˜) - $DNSMASQ_HOSTSFILE
--hostsfile-poll, -p How frequently to poll hosts file for changes (seconds, โ€˜0โ€˜ to disable) 0 $DNSMASQ_POLL
--search-domains, -s Comma delimited list of search domains domain[,domain] (supersedes /etc/resolv.conf) - $DNSMASQ_SEARCH_DOMAINS
--enable-search, -search Qualify names with search domains to resolve queries False $DNSMASQ_ENABLE_SEARCH
--rcache, -r Capacity of the response cache (โ€˜0โ€˜ disables caching) 0 $DNSMASQ_RCACHE
--rcache-ttl TTL for entries in the response cache 60 $DNSMASQ_RCACHE_TTL
--no-rec Disable forwarding of queries to upstream nameservers False $DNSMASQ_NOREC
--fwd-ndots Number of dots a name must have before the query is forwarded 0 $DNSMASQ_FWD_NDOTS
--ndots Number of dots a name must have before making an initial absolute query (supersedes /etc/resolv.conf) 1 $DNSMASQ_NDOTS
--round-robin Enable round robin of A/AAAA records False $DNSMASQ_RR
--systemd Bind to socket(s) activated by Systemd (ignores --listen) False $DNSMASQ_SYSTEMD
--verbose Enable verbose logging False $DNSMASQ_VERBOSE
--syslog Enable syslog logging False $DNSMASQ_SYSLOG
--multithreading Enable multithreading (experimental) False
--help, -h Show help
--version, -v Print the version

Enable Graphite/StatHat metrics

EnvVar: GRAPHITE_SERVER
Default:
Set to the host:port of the Graphite server

EnvVar: GRAPHITE_PREFIX
Default: go-dnsmasq
Set a custom prefix for Graphite metrics

EnvVar: STATHAT_USER
Default:
Set to your StatHat account email address

Usage

Run from the command line

Download the binary for your OS from the releases page.

go-dnsmasq is available in two versions. The minimal version (go-dnsmasq-min) has a lower memory footprint but doesn't have caching, stats reporting and systemd support.

   sudo ./go-dnsmasq [options]

Run as a Docker container

Docker Hub trusted builds are available.

docker run -d -p 53:53/udp -p 53:53 janeczku/go-dnsmasq:latest

You can pass go-dnsmasq configuration parameters by setting the corresponding environmental variables with Docker's -e flag.

Serving A/AAAA records from a hosts file

The --hostsfile parameter expects a standard plain text hosts file with the only difference being that a wildcard * in the left-most label of hostnames is allowed. Wildcard entries will match any subdomain that is not explicitly defined. For example, given a hosts file with the following content:

192.168.0.1 db1.db.local
192.168.0.2 *.db.local

Queries for db2.db.local would be answered with an A record pointing to 192.168.0.2, while queries for db1.db.local would yield an A record pointing to 192.168.0.1.

More Repositories

1

calibre-web

๐Ÿ“š Web app for browsing, reading and downloading eBooks stored in a Calibre database
Python
11,592
star
2

rancher-letsencrypt

๐Ÿฎ Rancher service that obtains and manages free SSL certificates from the Let's Encrypt CA
Go
324
star
3

haproxy-acme-validation-plugin

๐Ÿ€ Zero-downtime ACME / Let's Encrypt certificate issuing for HAProxy
Shell
293
star
4

docker-machine-vultr

โ“‚๏ธ Docker Machine driver for Vultr Cloud
Go
193
star
5

docker-dropbox

๐Ÿณ Dropbox in a Docker image. This works.
Shell
148
star
6

go-ipset

๐Ÿ”ฅ Go bindings for the IPtables ipset http://ipset.netfilter.org userspace utility
Go
119
star
7

docker-alpine-kubernetes

:octocat: Alpine Linux base image with support for DNS service discovery in Docker clusters
Shell
112
star
8

keepalived-ingress-vip

๐Ÿ’“ HA/IP failover solution for on-premises and bare-metal Kubernetes clusters.
Smarty
52
star
9

powerdns_exporter

๐Ÿ“ˆ Prometheus metrics exporter for PowerDNS
Go
34
star
10

go-rancher-gen

๐Ÿฎ Generate configuration files using templates and Rancher Metadata
Go
32
star
11

docker-calibre-web

๐Ÿณ Docker image for Calibre Web
Shell
32
star
12

terraform-rancheros-vmware

HCL
23
star
13

go-spinner

GO spinner / activity indicator for command line applications
Go
21
star
14

docker-nfs-ganesha

๐Ÿณ ๐Ÿšข NFS-Ganesha Docker Image
Shell
14
star
15

docker-shipyard-armv7

๐Ÿณ Shipyard Docker management for Raspberry Pi 2 / Scaleway C1
JavaScript
11
star
16

docker-alpine-haproxy

๐Ÿณ Haproxy docker image based on Alpine Linux
Makefile
10
star
17

go-redwall

๐Ÿ”ฅ Dockerized distributed dynamic firewall daemon with Redis backend
Go
8
star
18

Docker-RemoteSyslog2

๐Ÿณ Forward server or container logs to remote syslog collectors
Shell
8
star
19

meta-k3s

Shell
7
star
20

stdemuxerhook

๐Ÿ”€ A hook for logrus logger that demuxes logs to stderr and stdout based on severity
Go
6
star
21

datadog-rancher-init

๐Ÿถ Sidekick container image for running Datadog Agent in Rancher environments
Python
6
star
22

rancher-v2-logging

6
star
23

habitat-plans

Shell
4
star
24

ansible-k3s-2-node-ha

Ansible playbook for setting up a 2-node, high available k3s cluster using an embedded replicated database
Shell
4
star
25

tiny-operators-catalog

Shell
3
star
26

meta-k3s-odroid-c2

Shell
2
star
27

go-ipintel

๐Ÿ‘ฎ Go wrapper for the getipintel.net proxy detection API
Go
2
star
28

fleet-demo

2
star
29

nginx-php55

๐Ÿณ Nginx/PHP5.5/NodeJS/Ruby Docker image based on CentOS 7
Shell
1
star
30

k8s-nginx-demo

1
star
31

docker-armhf

๐Ÿณ Docker in Docker for ARMv7!
Shell
1
star
32

dotfiles

Shell
1
star
33

docker-selfoss-nginx

๐Ÿณ Selfoss - http://selfoss.aditu.de Docker image
PHP
1
star
34

helm-charts

Public Helm chart repository
1
star
35

k3s-fleet-demos

1
star
36

ndppd-alpine

Shell
1
star
37

blinken-k8s

Shell
1
star
38

docker-debian-nginx

๐Ÿณ Nginx 1.8 (Dotdeb) image based on Debian Wheezy
Shell
1
star
39

docker-debian-s6

๐Ÿณ Official debian images pimped with the s6 process supervisor
Shell
1
star
40

rancher-hello-world

Python
1
star