Gentoo Archives: gentoo-user

From: Michael Mol <mikemol@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] /etc/hosts include file?
Date: Fri, 08 Mar 2013 00:30:09
Message-Id: 513930FF.6030003@gmail.com
In Reply to: [gentoo-user] /etc/hosts include file? by Alan McKinnon
1 On 03/07/2013 05:24 PM, Alan McKinnon wrote:
2 > Anyone know if there's a way to get /etc/hosts to support the notion of
3 > an include file? I did my homework and found nothing, maybe someone else
4 > knows more.
5 >
6 > I really do need this, I have an app that discovers things on the
7 > network and knows their address. This makes it's automated way into DNS
8 > but takes a few days, and another app needs to use the fqdn right now.
9 > So /etc/hosts is the way to go for the interim three days.
10 >
11 > I've worked around it by creating /etc/hosts.d/ containing a header and
12 > a data file. cat the two and redirect to /etc/hosts.d/hosts and the real
13 > hosts file is a symlink to that. It's a sub-directory as none of these
14 > apps run as root and only root can modiy the real hosts file.
15 >
16 > This works well enough, but a supported include mechanism would make
17 > life so much simpler, not to mention easier for my colleagues to
18 > understand what the blazes I set up :-)
19
20 No, there's not an "include" directive.
21
22 There are, however, two other ways to get hostnames recognized.
23
24 The first is /etc/resolv.conf . You can point your host at a local DNS
25 server which is aware of the discovered hosts, and which forwards the
26 rest of the queries. (This is how Samba 4's internal DNS server
27 operates; anything it knows, it responds to. Everything else, it forwards.)
28
29 Read the manpage for resolv.conf...there's a lot of stuff in there
30 you'll want to know as you start coping with IPv6. (And some useful
31 stuff if you want to favor a particular IP range...)
32
33 The second is /etc/nsswitch.conf . nsswitch.conf is how you inject
34 samba-discovered, NIS-offered -- or whatever provider you care to inject
35 -- hostname databases into the system resolver. You could have it query
36 your provided database first, moving on to other sources if your
37 provided database doesn't have what you're looking for. (I'm actually
38 kinda surprised avahi doesn't come with an nss plugin...)

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-user] /etc/hosts include file? Alan McKinnon <alan.mckinnon@×××××.com>
Re: [gentoo-user] /etc/hosts include file? Florian Philipp <lists@×××××××××××.net>