<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Arial; font-size: 12pt; color: #000000'><font face="Arial" size="3">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:</font><div><font face="courier new, courier, monaco, monospace, sans-serif" size="2">[[ /etc/hosts.base -nt /etc/hosts || /etc/hosts.share -nt /etc/hosts ]] && cat /etc/hosts.base /etc/hosts.share > /etc/hosts</font></div><div><span style="font-family: Arial; ">It'll overwrite your /etc/hosts if you update your /etc/hosts.base or /etc/hosts.share file with the contents of both.</span></div><div><span style="font-family: Arial; "><br></span></div><div><span style="font-family: Arial; ">Scott</span></div><div><br><hr id="zwchr" style="color: rgb(0, 0, 0); font-family: Arial; font-size: 12pt; "><div style="color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-size: 12pt; font-weight: normal; font-style: normal; text-decoration: none; "><b>From: </b>"Wolf Halton" <wolf.halton@gmail.com><br><b>To: </b>"Atlanta Linux Enthusiasts" <ale@ale.org><br><b>Sent: </b>Thursday, July 12, 2012 2:14:21 PM<br><b>Subject: </b>Re: [ale] is there a bash command to include a file in /etc/hosts?<br><br>...<br><br>Exactly.<br>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.<br>
Yes, I can just add a host to the /etc/hosts file that has "192.168.0.23 <a href="http://wolfhalton.info" target="_blank">wolfhalton.info</a>" 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 <a href="http://cat.fish" target="_blank">http://cat.fish</a>. <br>
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.<br>I don't want to start making IPTables rules or adding to hosts.allow and hosts.deny.<br clear="all"><br></div></div></div></body></html>