xref: /netbsd-src/external/bsd/openresolv/dist/README.md (revision 91b0a986de1681d9dd8285b94a008ea6e59b9ad0)
16dab695bSroy# openresolv
26dab695bSroy
36dab695bSroyopenresolv is a [resolvconf](https://en.wikipedia.org/wiki/Resolvconf)
46dab695bSroyimplementation which manages `/etc/resolv.conf`.
56dab695bSroy
66dab695bSroy`/etc/resolv.conf` is a file that holds the configuration for the local
76dab695bSroyresolution of domain names.
86dab695bSroyNormally this file is either static or maintained by a local daemon,
96dab695bSroynormally a DHCP daemon. But what happens if more than one thing wants to
106dab695bSroycontrol the file?
116dab695bSroySay you have wired and wireless interfaces to different subnets and run a VPN
126dab695bSroyor two on top of that, how do you say which one controls the file?
136dab695bSroyIt's also not as easy as just adding and removing the nameservers each client
146dab695bSroyknows about as different clients could add the same nameservers.
156dab695bSroy
166dab695bSroyEnter resolvconf, the middleman between the network configuration services and
176dab695bSroy`/etc/resolv.conf`.
186dab695bSroyresolvconf itself is just a script that stores, removes and lists a full
196dab695bSroy`resolv.conf` generated for the interface. It then calls all the helper scripts
206dab695bSroyit knows about so it can configure the real `/etc/resolv.conf` and optionally
216dab695bSroyany local nameservers other than libc.
226dab695bSroy
236dab695bSroy## Reasons for using openresolv
246dab695bSroy
256dab695bSroyWhy openresolv over the
266dab695bSroy[Debian implementation](http://qref.sourceforge.net/Debian/reference/ch-gateway.en.html#s-dns-resolvconf)?
276dab695bSroyHere's some reasons:
286dab695bSroy  *  Works with
296dab695bSroy  [POSIX shell and userland](http://www.opengroup.org/onlinepubs/009695399)
306dab695bSroy  *  Does not need awk, grep or sed which means we can work without `/usr`
316dab695bSroy  mounted
326dab695bSroy  *  Works with other init systems than Debians' out of the box
336dab695bSroy  *  Available as a 2 clause
346dab695bSroy  [BSD license](http://www.freebsd.org/copyright/freebsd-license.html)
356dab695bSroy  *  Prefer configs via IF_METRIC for dynamic ordering
366dab695bSroy  *  Configures zones for local resolvers other than libc
376dab695bSroy
386dab695bSroyThe last point is quite important, especially when running VPN systems.
396dab695bSroyTake the following resolv.conf files which have been generated by a
40*91b0a986Sroy[DHCP client](https://github.com/NetworkConfiguration/dhcpcd) and sent to resolvconf:
416dab695bSroy
426dab695bSroy```
436dab695bSroy# resolv.conf from bge0
446dab695bSroysearch foo.com
456dab695bSroynameserver 1.2.3.4
466dab695bSroy
476dab695bSroy# resolv.conf from tap0
486dab695bSroydomain bar.org
496dab695bSroynameserver 5.6.7.8
506dab695bSroy```
516dab695bSroy
526dab695bSroyIn this instance, queries for foo.com will go to 1.2.3.4 and queries for
536dab695bSroybar.org will go to 5.6.7.8.
546dab695bSroyThis does require the resolvers to be configured to pickup the resolvconf
556dab695bSroygenerated configuration for them though.
566dab695bSroyopenresolv ships with helpers for:
576dab695bSroy  *  [unbound](http://www.unbound.net/)
586dab695bSroy  *  [dnsmasq](http://www.thekelleys.org.uk/dnsmasq/doc.html)
596dab695bSroy  *  [ISC BIND](http://www.isc.org/software/bind)
606dab695bSroy  *  [PowerDNS Recursor](http://wiki.powerdns.com/trac)
616dab695bSroy
626dab695bSroySee the
63*91b0a986Sroy[configuration section](https://roy.marples.name/projects/openresolv/configuration)
646dab695bSroyfor more details.
65def83e6aSroy
66def83e6aSroyIf openresolv updates `/etc/resolv.conf` it can notify the following of this:
67def83e6aSroy  *  [Bonjour (mdnsd)](https://developer.apple.com/bonjour/)
68def83e6aSroy  *  [avahi](http://www.avahi.org/)
69