Ok, a little hair pulling (and I don't have many to spare) and we got it!
- Tellsv.9.zip
- A working set for intra-LAN DNS
- (3.5 KiB) Downloaded 477 times
Here's how to use this stuff.
Extract the zip.
copy tellem and tellme to /usr/bin (or someplace else they are likely to be safe, executable and on the path). Ensure they are executable there using the normal linux tools for that.
For ease of use, I'll either use a terminal and sudo with the cp command, or say something like sudo nautilus to the terminal so I can adjust "properties" and owners of things via right click on them.
tellem doesn't need any special privileges to work, it can be owned by "yourusername" or root as you prefer (but probably not owned by doug unless that's your name too, you'll have to change that one perhaps). I got that running by using the system/preferences/startup programs dialogs. For whatever reason, it didn't start working till about 2 reboots after that, and you might want to do what I did for tellme instead. For that, I used and upstart configuration file in /etc/init that you can copy, rename, and change the name of the program executed by it. Not too horrible, and that seems more reliable than the user-space "startup programs" kludge.
Once you have tellme in /usr/bin, you need to change it's ownership to root, and do something like "chmod 6711 tellme" while you are root in that directory. This one, since it writes a root-owned file, /etc/hosts, needs real privileges and linux is rightly very careful about running things as root. It's also picky about who owned the world when it started - it can't escalate its privileges after starting on most distros (this is good!). Therefore, the startup applications thing does NOT work for this (it assumes your normal user privileges and runs things as you), instead, there is provided a tellme.conf file in the zip. You copy this to /etc/init/, which will already have a ton of .conf files in it. This file can be owned by you as well - it doesn't need to be root or have special privileges (oops, I smell a gaping linux security hole here, and this one ain't my fault). This will get tellme started as root on startup.
To see if this stuff is working, use the system monitor, under processes, and edit your preferences so you see "all processes", not just yours. If tellme and tellem are there, you're golden. If not, well...they can't work if they aren't running.
Now, here's how it all works. Tellem simply broadcasts a machine's name and IP over UDP broadcast to the LAN, periodically. For grins, I used a semi-random number to tell it how long to sleep between broadcasts, and it's always a large number on the order of 60 seconds or so - machines don't come and go that fast, and why clog up the LAN or waste CPU?
Anybody who wants this info, and wants it put into /etc/hosts (which is checked before any DNS for name resolution), runs tellme. If you don't like automation, you could just run it from a terminal of course - as root, or it'll die right away the first time it tries to write the hosts file. You'd say something like "sudo tellme" to do that - or add an ampersand after the program path if you want to disconnect from it, though if debug is set, it will still print junk there. It sits and listens for those broadcasts from the rest of the lan (and yourself if you are also running tellem - broadcasts come home too).
It's smart enough to ignore broadcasts from localhost, which would overwrite the faster internal loopback for yourself in the hosts file, but any other change - even a machine that somehow changes its IP on the fly, it will pick up on - that was the entire point, after all. This case can happen here because I have one multi-homed host (more than one NIC) and sometimes it will report the wired NIC, sometimes the wireless if I've unplugged the cable on the wired connection. Which was the entire point here - I unplug this when running that nasty 50kv power supply right next to the machine that does data aq - because we don't want to couple a megawatt arc into the rest of the LAN no matter what. I've also found that restarting a machine on my LAN might make it get a different IP address as well, and I'd rather just remember the machine name than do arp-scan or something.
So, tellme maintains some hashes of info, and when there's a change or it hasn't heard anything from a machine named in one of the hashes for 2 minutes, it recomposes and rewrites the /etc/hosts file with proper syntax. It will also do this immediately on boot up, as it defaults to "changed" at that point, since the last time you ran, you might have had a bunch of other entries in your hosts file, and now those machines aren't on - so no need to wait 2 minutes to repair that - it does it right away on boot.
Note, if you've added a bunch of junk to your hosts file, this will wipe it. You can fix that by adding your special stuff into the "here document" I use to put back the ipv6 junk my original hosts file had in it.
This is like some other designs I do, that I get some complaints about - like when someone duped my preamp design and utterly ignored the fact that I spent years eliminating things it didn't need, and in serious component selection - it only works the way I showed it, not just any old bunch of substituted junk will do. The word is "beware the wires/components that aren't there, because I designed this to not need them" - Don't think (except at your own risk) that you can fiddle this because I obviously missed something, unless you're either as good/better as me, or into serious pain and suffering. This works as is.
And now, with this installed on my net, I can simply type things like "server/" into a browser and hit the apache server on server - or any other machine I have that has a web server on it (all of them). Further, I can now populate drop-down lists and stuff in other programs, so that my data aq can go to any machine on the LAN that is running mysql (all of them, but I'd usually use my machine named server, which was custom built just for that - SSD's and all, it's serious stuff).
So, whether the phone company is working or not, my LAN can (and does) look like a miniature, simplified internet, all the stuff works that would work whether a machine is here or across the planet.
Now, if your internal lan isn't of the form 192.168.1.???\8, then you'll have to edit things that look like that in the programs to reflect your default LAN setup. They tend to be at the top of tellem as a variable set to that, or in a test in the routine in tellem called mynetinfo (so as to eliminate really weird responses I get from another nic that isn't really on my LAN at all). Should be obvious what to do there. .255 as the last number in the IP is always going to be the broadcast address.
If the port I used, 53831, is already in use on your lan for something, you'll have to change that too - I just used my birthday since it got me above the already assigned ports for most machines, hence the joke in the comments.
But it works now, and well, YAY
And now I can get on with what I needed this for - a scheme to push realtime data acquisition into a database on another machine, instead of using a mere log file on the machine doing the acquisition. That approach had two flaws (that I've run into). For one, I sometimes forget to tell my data aq to even make a log file, and while you can recover from that by doing ctrl-a, ctrl-c, then ctrl-v into an editor (from the data aq edit box), that's not in the right format, and I had to write another perl script to make the format right again (add all the text labels back between the numbers). Also, in the event of "lightning" - things lock up, the file isn't closed, that machine might be toast totally - and any data stored on it is just a dream - and that has happened more times than my wallet is happy with already. This way, the data goes out line by line to another machine that's a long way off, and very safe, and if we lose it in the middle, so be it - the mysql database won't mind and what we got, we really have gotten and safely.
Now for the fun parts. This was a bit of digging deep into more sysadmin-type stuff than even I like doing. But it's done now, and the fun can begin with "real" things.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.