[ale] is there a bash command to include a file in /etc/hosts?

Scott Plante splante at insightsys.com
Fri Jul 13 11:31:28 EDT 2012


I like the puppet and the internal DNS ideas better, but if you want something quick an dirty you could put a command like this in your crontab: 
[[ /etc/ hosts.base -nt /etc/ hosts || /etc/ hosts.share -nt /etc/ hosts ]] && cat /etc/ hosts.base /etc/ hosts.share > /etc/hosts 
It'll overwrite your /etc/hosts if you update your /etc/hosts.base or /etc/hosts.share file with the contents of both. 


Scott 

----- Original Message -----

From: "Wolf Halton" <wolf.halton at gmail.com> 
To: "Atlanta Linux Enthusiasts" <ale at ale.org> 
Sent: Thursday, July 12, 2012 2:14:21 PM 
Subject: Re: [ale] is there a bash command to include a file in /etc/hosts? 

... 

Exactly. 
I want to use a variation on DNS that lets me name my internal machines the same names as their FQDN so that the machines work with each other exactly how they work with hosts outside my private network. One of the rules the firewall admins require is that one host in the private range may not send packets out through the firewall that will eventually loop back through the firewall to another host on the internal network. 
Yes, I can just add a host to the /etc/hosts file that has "192.168.0.23 wolfhalton.info " as the recipient's IP mapping, but I wanted to have a file I could drop into any of my local machines with the local info, so if I want to make changes in the internal networking, I can just change the file and distribute it where it is needed. Keeps the hosts file uncluttered. I can also map IPs to non-authentic FQDNs like cat.fish, dog.fish and so on with this scheme, if I want to. I cannot distribute the names to my nameservers so nobody external will be able to find http://cat.fish . 
The other option that might work is to modify the resolv system so it looks for hosts and hosts2 before looking for a DNS service. 
I don't want to start making IPTables rules or adding to hosts.allow and hosts.deny. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20120713/1d92a403/attachment.html 


More information about the Ale mailing list