On 08/03/2013 06:30, Pandu Poluan wrote: > > On Mar 8, 2013 5:27 AM, "Alan McKinnon" <alan.mckin...@gmail.com > <mailto:alan.mckin...@gmail.com>> wrote: >> >> Anyone know if there's a way to get /etc/hosts to support the notion of >> an include file? I did my homework and found nothing, maybe someone else >> knows more. >> >> I really do need this, I have an app that discovers things on the >> network and knows their address. This makes it's automated way into DNS >> but takes a few days, and another app needs to use the fqdn right now. >> So /etc/hosts is the way to go for the interim three days. >> >> I've worked around it by creating /etc/hosts.d/ containing a header and >> a data file. cat the two and redirect to /etc/hosts.d/hosts and the real >> hosts file is a symlink to that. It's a sub-directory as none of these >> apps run as root and only root can modiy the real hosts file. >> >> This works well enough, but a supported include mechanism would make >> life so much simpler, not to mention easier for my colleagues to >> understand what the blazes I set up :-) >> >> >> >> -- >> Alan McKinnon >> alan.mckin...@gmail.com <mailto:alan.mckin...@gmail.com> >> >> >> > > An option would be to create a cron job which generates the hosts file > every minute. The cron job should also insert a header on top of the > hosts file telling: > > + this file (hosts) is dynamically generated > + by a system cron job > + the cron job's script location > > Besides, you said you're going to need this workaround only for a couple > of days, so installing Samba4 might be an overkill.
I'm already doing something very much like that, I reckon I'll leave it in place, and document it in the grand CYA tradition. To be clear, it's not a temporary workaround - it's permanent. I do network discovery every 12 hours and can find up to 7000 things on the network, so now I know their hostname and address. This eventually makes it's way into DNS, but DNS by design updates slowly and a second app (an audit app) needs to resolve the names immediately. That's why hosts is the perfect interim solution; in 3 days when the DNS update happens the entry is removed from the hosts file. -- -- Alan McKinnon alan.mckin...@gmail.com