Well, I'm stuck with a telco ADSL router I'm not allowed to fiddle, and it insists everything connected to it use DHCP.
This means that as my many machines are power cycled, there's no guarantee they will have the same IP address they had last time. Since I do research (fusion, as you might guess from my nic), and do a lot of data acquisition to support that, I wanted to be able to use machine names in scripts to find a MySQL data base, for example, to log data to. Some people would use bind, but I found that too weighty and strange to configure. So, as I often do, I rolled my own. While I'm sure someone could do a tighter or more elegant version in C, I did this in perl - it works well enough.
There are two programs involved, both of which fork off and become daemons, and use very little CPU.
The resolving daemon writes to /etc/hosts, which is checked first before any external DNS, so my scripts can find out what's online via looking at that file, find a webserver on a machine by just using its name in the url bar of a browrser, stuff like that. No more sneaker-net to run ifconfig to find out what the IP addie of this machine is just now.
What it does is each machine broadcasts via UDP its name/address pair, about once a minute when it's up.
That daemon is called "tellem" - it tells everyone you're here and what your name is. Just in case, tellem broadcasts each machine's info at a semi-random time averaging about 1/minute. The idea was to prevent collision storms (not really needed, but...).
The second daemon is called "tellme". It keeps track of any changes to online status and updates its /etc/hosts as required. It needs to be run as /root so it can write the /etc/hosts file. I originally wrote this for a batch (around 20) PC's, but was pleasantly surprised that it works fine with the pi too, though the install procedure might be a little different, it was so easy I forgot how I did it here (I'm posting from a pi right now). IIRC, I just called them from one of the init.d scripts, where you're root anyway. Hey, this is the advanced users forum, I'm sure you'll figure it out.
The tellme daemon simple keeps a hash of what its seen, and the age since it last saw that machine. Anyone who doesn't report in 2 min or so - they get erased from /etc/hosts. Anyone new gets written into /etc/hosts right away. This makes all manner of intra-lan things "just work" - connections to databases, the web server I tend to put on each machine, and so on. /etc/hosts isn't disturbed if no change would be made. There's more info on why and how here on my own forums: http://www.coultersmithing.com/forums/v ... f=33&t=687
But here's the goodie file (latest version which really works right):
It sure had made my life easier (along with some other scripts that keep databases in sync - which are now a lot simpler). I've had to adopt some rather strange practices due to running on solar power - as in, I don't have any machine "always on", though what I'm working towards with the pi is to have that - I can afford its tiny power use easily even 24/7 on my "huge UPS system". Not so much a laptop or mini-itx drawing 10x the power.