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 13:40:50
Message-Id: 5139EA4D.1000606@gmail.com
In Reply to: Re: [gentoo-user] /etc/hosts include file? by Alan McKinnon
1 On 03/08/2013 03:32 AM, Alan McKinnon wrote:
2 > On 08/03/2013 02:29, Michael Mol wrote:
3 >> On 03/07/2013 05:24 PM, Alan McKinnon wrote:
4 >>> Anyone know if there's a way to get /etc/hosts to support the notion of
5 >>> an include file? I did my homework and found nothing, maybe someone else
6 >>> knows more.
7 >>>
8 >>> I really do need this, I have an app that discovers things on the
9 >>> network and knows their address. This makes it's automated way into DNS
10 >>> but takes a few days, and another app needs to use the fqdn right now.
11 >>> So /etc/hosts is the way to go for the interim three days.
12 >>>
13 >>> I've worked around it by creating /etc/hosts.d/ containing a header and
14 >>> a data file. cat the two and redirect to /etc/hosts.d/hosts and the real
15 >>> hosts file is a symlink to that. It's a sub-directory as none of these
16 >>> apps run as root and only root can modiy the real hosts file.
17 >>>
18 >>> This works well enough, but a supported include mechanism would make
19 >>> life so much simpler, not to mention easier for my colleagues to
20 >>> understand what the blazes I set up :-)
21 >>
22 >> No, there's not an "include" directive.
23 >>
24 >> There are, however, two other ways to get hostnames recognized.
25 >>
26 >> The first is /etc/resolv.conf . You can point your host at a local DNS
27 >> server which is aware of the discovered hosts, and which forwards the
28 >> rest of the queries. (This is how Samba 4's internal DNS server
29 >> operates; anything it knows, it responds to. Everything else, it forwards.)
30 >>
31 >> Read the manpage for resolv.conf...there's a lot of stuff in there
32 >> you'll want to know as you start coping with IPv6. (And some useful
33 >> stuff if you want to favor a particular IP range...)
34 >
35 > And the day started off so well. Then you had to come along and mention
36 > IPv6.... :-)
37 >
38 > IPv6 is wonderfully easy to use client-side and reasonably easy to plug
39 > into an existing network (the routers mostly know what to do already).
40 > The fun starts when you need to write an app that tracks and does range
41 > allocations at ISP scale, all while keeping the PTRs in line too. Sadly
42 > for me, my team works in that area and such a magic app is one of our
43 > deliverables
44
45 My mouth is watering...
46
47 >
48 > One day when I've climbed down off the walls and my fingernails have
49 > grown back, I might be up to relating what it is taking to get that
50 > done.... :-)
51
52 I don't suppose you knew I'm a huge IPv6 advocate, and travel around my
53 state giving free training sessions...
54
55 I would absolutely love to hear about the problems you're facing.
56 Further, I'd love to help you get past them...and can put you in touch
57 with experts who might also be able to help.
58
59
60 >
61 >>
62 >> The second is /etc/nsswitch.conf . nsswitch.conf is how you inject
63 >> samba-discovered, NIS-offered -- or whatever provider you care to inject
64 >> -- hostname databases into the system resolver. You could have it query
65 >> your provided database first, moving on to other sources if your
66 >> provided database doesn't have what you're looking for. (I'm actually
67 >> kinda surprised avahi doesn't come with an nss plugin...)
68 >
69 > One day I should read nsswitch's man page completely. I never needed to
70 > know more than "dns files" for the hosts directives and that shadow does
71 > user. All those other lookup schemes are things I never use.
72
73 I've never mucked with NIS, but I muck with samba from time to time.
74
75 If you're already in a developer context, I'd suggest writing an NSS
76 plugin the system resolver can check on. That's the angle I'd take in
77 your circumstance.

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>