[Dnsmasq-discuss] [PATCH] Support --server syntax in resolv-file

Simon Kelley simon at thekelleys.org.uk
Fri Apr 7 22:27:31 BST 2017

The overriding objection to this is that it adds to the syntax and
semantics of the resolv-file format, but dnsmasq doesn't "own" that
format: it's actually a libc configuration file, and dnsmasq takes
advantage of the fact that the format is "well known" to extract useful
information from it. If you start adding extra fields to
/etc/resolv.conf then the c-library will get upset.

I understand the desire to be able to specify resolvers dynamically with
the full set of source-address and routing options; that's actually
already available, and has been for a long time, using the DBus
interface to dnsmasq, which includes the "SetDomainServers" method,
which takes strings identical to argument to --server. I've not looked
at the code, but your previous patch to allow binding both IP and
interface should have automatically added that feature to
SetDomainServers. (if it didn't then I'd certainly take a patch to
correct that.)



On 23/03/17 18:16, Kristian Evensen wrote:
> Automatically specifying which source address and interface to be used for
> communicating with a given DNS server is very convenient on multihomed hosts.
> Two use-cases I have had for this feature are:
> * Several mobile broadband providers hand out private IP-addresses, but the DNS
> servers are global. Unless special routing rules are added, then the default
> route will be used for resolving domains. This is not ideal, as it might lead to
> higher latencies for replies, or an additional cost to the user if DNS requests
> to the "local" servers are free.
> * Several mobile broadband devices act as small routers, and some of the most
> popular types only hand out the same IP, DNS server, etc. To make matters worse,
> if these devices loose connectivity, they will highjack any DNS request and
> reply with its own IP. If you have multiple of these devices, you risk being
> stuck without working DNS as all requests might be forwarded to the disconnected
> device. Adding support for binding to interface and IP will make sure that
> requests are sent to the correct device. Some external tool will still be
> required to check that DNS is working fine and updating the resolv-file
> accordingly.
> Dnsmasq already supports reading and binding to an ip-adress/interface through
> the --server option. This patch adds support for specifying which source address
> and/or interface to use for a server in the resolv-file, using the same syntax
> as for --server. For example, in order to specify that source ip
> and interface wwan1 should be used to communicate with server, the
> following line would have to be added to the resolv-file:
> nameserver at
> Since the syntax is not standard, the --multihomed-resolver command line option
> must be enabled. Please note that lines with and without source
> address/interface can be mixed.
> Since we now have two places where the interface-part of --server is parsed, I
> have factored out this parsing into a separate function. parse_server() is
> converted to use this function.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20170407/81d7e8c4/attachment.sig>

More information about the Dnsmasq-discuss mailing list