|
1 | 1 | # go-dnsmasq |
2 | 2 | *Version 0.9.8* |
3 | 3 |
|
4 | | -go-dnsmasq is a light weight (1.2 MB) DNS caching server/forwarder with minimal filesystem and runtime overhead. It is designed to serve global DNS records by forwarding queries to upstream nameservers as well as local hostname records from a hostsfile. |
| 4 | +go-dnsmasq is a light weight (1.2 MB) DNS caching server/forwarder with minimal filesystem and runtime overhead. |
5 | 5 |
|
6 | 6 | ### Application examples: |
7 | 7 |
|
8 | | -- as local DNS cache for Docker containers |
9 | | -- as nameserver providing local and global DNS records to clients in a private networks |
10 | | -- as DNS proxy providing `search` domain path capability to `musl-libc` based clients (e.g. Alpine Linux) |
| 8 | +- Caching DNS server/forwarder in a local network |
| 9 | +- Container/Host DNS cache |
| 10 | +- DNS proxy providing DNS `search` capabilities to `musl-libc` based clients, particularly Alpine Linux |
11 | 11 |
|
12 | 12 | ### Features |
13 | 13 |
|
14 | | -* Parses upstream nameservers from resolv.conf |
15 | | -* Configures itself as local DNS cache in resolv.conf |
16 | | -* Serves static hostname records from a hostsfile |
17 | | -* Caching of answers |
18 | | -* Replicates the `search` domain suffixing not supported by `musl-libc` based Linux distributions. |
19 | | -* Stubzones (use a different nameserver for specific domains) |
20 | | -* Round-robin of address records |
21 | | -* Sending stats to Graphite server |
22 | | -* Configuration through CLI and environment variables |
23 | | - |
24 | | -### Resolver logic |
25 | | - |
26 | | -DNS queries are processed according to the logic used by the GNU C resolver library: |
27 | | -* The first nameserver (as listed in resolv.conf or configured by `--nameservers`) is considered the primary server. Additional servers are queried only when the primary server times out or returns an error code. |
28 | | -* Multiple `search` paths are tried in the order they are configured. |
29 | | -* Single-label queries (e.g.: "redis-service") will always be qualified with `search` list elements |
30 | | -* For multi-label queries (ndots >= 1) the name will be tried first as an absolute name before any `search` list elements are appended to it. |
31 | | - |
32 | | -### Commandline options |
33 | | - |
34 | | -```sh |
35 | | -NAME: |
36 | | - go-dnsmasq - Lightweight caching DNS proxy for Docker containers |
37 | | - |
38 | | -USAGE: |
39 | | - go-dnsmasq [global options] command [command options] [arguments...] |
40 | | - |
41 | | -VERSION: |
42 | | - 0.9.8 |
43 | | - |
44 | | -COMMANDS: |
45 | | - help, h Shows a list of commands or help for one command |
46 | | - |
47 | | -GLOBAL OPTIONS: |
48 | | - --listen, -l "127.0.0.1:53" listen address: ‘host[:port]‘ [$DNSMASQ_LISTEN] |
49 | | - --default-resolver, -d make go-dnsmasq the local primary nameserver (updates /etc/resolv.conf) [$DNSMASQ_DEFAULT] |
50 | | - --nameservers, -n comma-separated list of name servers: ‘host[:port]‘ [$DNSMASQ_SERVERS] |
51 | | - --stubzones, -z domains to resolve using a specific nameserver: ‘fqdn[,fqdn]/host[:port]‘ [$DNSMASQ_STUB] |
52 | | - --hostsfile, -f full path to hostsfile (e.g. ‘/etc/hosts‘) [$DNSMASQ_HOSTSFILE] |
53 | | - --hostsfile-poll, -p "0" how frequently to poll hostsfile (in seconds, ‘0‘ to disable) [$DNSMASQ_POLL] |
54 | | - --search-domains, -s specify SEARCH domains taking precedence over /etc/resolv.conf: ‘fqdn[,fqdn]‘ [$DNSMASQ_SEARCH] |
55 | | - --append-search-domains, -a enable suffixing single-label queries with SEARCH domains [$DNSMASQ_APPEND] |
56 | | - --rcache, -r "0" capacity of the response cache (‘0‘ to disable caching) [$DNSMASQ_RCACHE] |
57 | | - --rcache-ttl "60" TTL of entries in the response cache [$DNSMASQ_RCACHE_TTL] |
58 | | - --no-rec disable recursion [$DNSMASQ_NOREC] |
59 | | - --round-robin enable round robin of A/AAAA replies [$DNSMASQ_RR] |
60 | | - --systemd bind to socket(s) activated by systemd (ignores --listen) [$DNSMASQ_SYSTEMD] |
61 | | - --verbose enable verbose logging [$DNSMASQ_VERBOSE] |
62 | | - --syslog enable syslog logging [$DNSMASQ_SYSLOG] |
63 | | - --multithreading enable multithreading (num physical CPU cores) [$DNSMASQ_MULTITHREADING] |
64 | | - --help, -h show help |
65 | | - --version, -v print the version |
66 | | -``` |
67 | | - |
68 | | -### Environment Variables |
69 | | - |
70 | | -See above (the names inside the brackets). |
| 14 | +* Automatically set upstream `nameservers` and `search` domains from resolv.conf |
| 15 | +* Insert itself into the host's /etc/resolv.conf on start |
| 16 | +* Serve static A/AAAA records from a hostsfile |
| 17 | +* Provide DNS response caching |
| 18 | +* Replicate the `search` domain treatment not supported by `musl-libc` based Linux distributions |
| 19 | +* Supports virtually unlimited number of `search` paths and `nameservers` ([related Kubernetes article](https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/dns#known-issues)) |
| 20 | +* Configure stubzones (different nameserver for specific domains) |
| 21 | +* Round-robin of DNS records |
| 22 | +* Send server metrics to Graphite and StatHat |
| 23 | +* Configuration through both command line flags and environment variables |
| 24 | + |
| 25 | +### Resolve logic |
| 26 | + |
| 27 | +DNS queries are resolved in the style of the GNU libc resolver: |
| 28 | +* The first nameserver (as listed in resolv.conf or configured by `--nameservers`) is always queried first, additional servers are considered fallbacks |
| 29 | +* Multiple `search` domains are tried in the order they are configured. |
| 30 | +* Single-label queries (e.g.: "redis-service") are always qualified with the `search` domains |
| 31 | +* Multi-label queries (ndots >= 1) are first tried as absolute names before qualifying them with the `search` domains |
| 32 | + |
| 33 | +### Command-line options / environment variables |
| 34 | + |
| 35 | +| Flag | Description | Default | Environment vars | |
| 36 | +| ------------------------------ | ----------------------------------------------------------------------------- | ------------- | -------------------- | |
| 37 | +| --listen, -l | Address to listen on `host[:port]` | 127.0.0.1:53 | $DNSMASQ_LISTEN | |
| 38 | +| --default-resolver, -d | Update resolv.conf and make go-dnsmasq the host's primary nameserver | False | $DNSMASQ_DEFAULT | |
| 39 | +| --nameservers, -n | Comma-separated list of nameservers `host[:port]` | - | $DNSMASQ_SERVERS | |
| 40 | +| --stubzones, -z | Use different nameservers for specific domains `fqdn[,fqdn]/host[:port]` | - | $DNSMASQ_STUB | |
| 41 | +| --hostsfile, -f | Full path to a hostsfile | - | $DNSMASQ_HOSTSFILE | |
| 42 | +| --hostsfile-poll, -p | How frequently to check hostsfile for changes (seconds, ‘0‘ to disable) | 0 | $DNSMASQ_POLL | |
| 43 | +| --search-domains, -s | Specify SEARCH domains (takes precedence over /etc/resolv.conf) `fqdn[,fqdn]` | - | $DNSMASQ_SEARCH | |
| 44 | +| --append-search-domains, -a | Qualify queries with SEARCH domains | False | $DNSMASQ_APPEND | |
| 45 | +| --rcache, -r | Capacity of the response cache (‘0‘ to disable cache) | 0 | $DNSMASQ_RCACHE | |
| 46 | +| --rcache-ttl | TTL for entries in the response cache | 60 | $DNSMASQ_RCACHE_TTL | |
| 47 | +| --no-rec | Disable recursion | False | $DNSMASQ_NOREC | |
| 48 | +| --round-robin | enable round robin of A/AAAA records | False | $DNSMASQ_RR | |
| 49 | +| --systemd | Bind to socket(s) activated by Systemd (ignores --listen) | False | $DNSMASQ_SYSTEMD | |
| 50 | +| --verbose | Enable verbose logging | False | $DNSMASQ_VERBOSE | |
| 51 | +| --syslog | Log to syslog | False | $DNSMASQ_SYSLOG | |
| 52 | +| --multithreading | Enable multithreading | False | | |
| 53 | +| --help, -h | Show help | | | |
| 54 | +| --version, -v | Print the version | | | |
| 55 | + |
| 56 | +#### Enable Graphite/StatHat metrics |
| 57 | + |
| 58 | +EnvVar: **GRAPHITE_SERVER** |
| 59 | +Default: ` ` |
| 60 | +Set to the `host:port` of the Graphite server |
| 61 | + |
| 62 | +EnvVar: **GRAPHITE_PREFIX** |
| 63 | +Default: `go-dnsmasq` |
| 64 | +Set a custom prefix for Graphite metrics |
| 65 | + |
| 66 | +EnvVar: **STATHAT_USER** |
| 67 | +Default: ` ` |
| 68 | +Set to your StatHat account email address |
71 | 69 |
|
72 | 70 | ### Usage |
73 | 71 |
|
|
0 commit comments