3

If I understand /etc/nsswitch.conf correctly, the configuration

hosts:          files mdns4_minimal [NOTFOUND=return] dns

results in interpreting /etc/hosts, MDNS and finally "regular" DNS servers.

Now I would love to have an option to set some static fallback definitions in case all previous resolving options failed.

Switching DNS and files would probably a bad idea because it would call DNS servers everytime.

So basically I'm looking for a solution that will work in case a DNS server failed (and there was no match in /etc/hosts obviously).

If this solution would result in a file manageable per user it would be even perfect.

1 Answer 1

2

You can't, at least with the NSS (Name Service Switch) implemetation of glibc.

You can obviously use an action for a service (like the mdns4_minimal is using [NOTFOUND=return] in your example). It's of the form:

[STATUS=ACTION]

with a preceding ! will negate the status.

The STATUS can be any one of the following four:

  • SUCCESS
  • NOTFOUND
  • UNAVAIL
  • TRYAGAIN

and ACTION can be any one of the following two:

  • RETURN
  • CONTINUE

Here RETURN will return a result without looking any further lookup functions, and CONTINUE will continue to look further. There is no way to mention a file to fallback.

You are basically looking for something like:

hosts:   files mdns4_minimal [NOTFOUND=return] dns [NOTFOUND=/read/for/this/file]

which is not possible.

In a nutshell, you are looking for an non-existent ACTION of nsswitch.

2
  • Thank you for your response. What a pity! Would it be possible to delare similar rules for dnsmasq? Or do I think into the wrong direction? Oct 21, 2016 at 19:38
  • 1
    @Wurstsalat You are looking at the wrong direction. DNSs are not designed for any fallbacking. When you ask for a name resolution, you DNS server asks authoritative name servers for that domain, and get you the result and also caches the result for TTL amount of time. There is no fallbacking involved here. If the domain does not exist or DNS server is unreachable you'll see relevant response. dnsmasq is a lightweight resolver with caching facility.
    – heemayl
    Oct 21, 2016 at 19:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .