DNS for my LAN

For PC type software that runs under some PC opsys.

Re: DNS for my LAN

Postby Doug Coulter » Mon Jan 07, 2013 6:11 pm

Just a note - I've now installed this pair on all 4 in-use machines on this part of my LAN (haven't gotten around to the other buildings on campus yet, except for the one that has the loo in it and a wireless-connected laptop, so that's 5 total).

Works 100%/seamless/flawless everywhere on both ubuntu 10.04 and 12.04. It's more hassle to put into 12.04 because EVERYTHING IS HARDER IN GNOME 3 or UNITY. It makes you realize the command line isn't so bad after fighting that ignorant attempt at a phone GUI on a desktop.

I guess I was being too linux-y to call it version 0.9. But then, I have no feedback from other users yet. It does accomplish the intended goal, and I can now see the mysql instance on "server" from "Fuze3" which is the currently active data aq machine downstairs, wired or wireless or both. It appears to work with anything that can use a URL as input - browsers, mysql clients (but you have to do some things on mysql to allow remote access), and so forth. Very nice. Somewhere along the way I found a file that had URL resolution order in it, with the comment that "old C programs still use this" with a line that said hosts, DNS - everything checks /etc/hosts first no matter what, so that's probably why it works so well.

This code might work on BSD/Apple OSX with minor changes - they work about the same as linux.

I should probably get interested in re-doing all this in C, not for speed (it's loafing) but for memory footprint. I'd offer a nominal sum (think dinner at a nice place), since I really don't care that much about 1 meg (about what these use - each spawns an instance of the perl interpreter, and includes some modules from which only one function is used), and I don't care enough to do it myself.

An installer script would be nice too - as would be a windows version, but I have no idea how you'd do this in windows, as it doesn't have the equivalent of /etc/hosts as far as I know, for local name to IP resolution (I'm sure it has something via netbios but how to tap into that?).
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.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: DNS for my LAN

Postby solar_dave » Tue Jan 08, 2013 10:28 am

Doug winders does have an /etc/hosts down under the system32 directory structure some place.

Let me look at your Perl code, I bet I could do a 'C' version in a couple hours. It would probably have to run setuid though but then you could run as any user. Are you looking for a Debian pkg or rpm as the installed on Linux? Or just a tar install to the proper locations?
Dave Shiels

My TED 5000 power monitoring
http://phx-solar.no-ip.info:8081/Footprints.html
solar_dave
 
Posts: 108
Joined: Tue Aug 21, 2012 12:33 pm
Location: Phoenix, AZ

Re: DNS for my LAN

Postby Doug Coulter » Tue Jan 08, 2013 11:35 am

The code is in the zip above (Tellsv.9.zip) if you want to look at it; use something that syntax highlights perl - I use gedit, but there are a few others that work out there.
If you're on linux, geany and padre should also do.

Tellem seems to need no special privileges at all - it just needs to run on startup and sit in the background - all it does is grab the local host info and broadcast it on UDP every minute or so. I have it read the info every time, since various things might make it change - and the other end handles those changes should they occur.

Tellme, since it writes a root-owned file in the non-world-writeable /etc directory (hosts), needs to be run setuid or as root. I did copy them to usr/bin (writeable only by root itself) with the command line sudo cp tellme /usr/bin (which also makes them root-owned on the fly during the copy) I'm not sure if I needed to cd to /usr/bin and then do chmod 6711 for both, but I did anyway. Tellme is the one that's hard to get going at startup. If the privileges aren't right, it dies the first time it wants to write the hosts file. Which is the first thing it tries to do at this point, just to get one "clean" at first if it wasn't at the last shutdown.

For linux, an acceptable install script would simply be a script in any language you invoked like "sudo install", which would do those copies and chmods for you - could be part of a zip you give people just like the one above, but with another program to put the other 3 files where they belong. To get tellme to really run at startup, and as root, I had to put a .conf file in /etc/init for it, which is in that zip above - this is processed by init (or the newer upstart) at boot time. The same sort of thing with a name change would work for tellem, but isn't required - that one's easy, but it might be cleaner from the user's or sysadmin's pov.

A .deb would be great, but probably overkill in terms of the effort required to make it (dunno, haven't made one myself). At any rate, at some point you need to be root to do some of the required things.

This stuff would probably run on windows if it had perl (there is one available from active state, free) but I don't think windows supports all the posix stuff, though there's certainly a way to not need that there, you just need admin and to be a service (daemon) no matter how you do it, and that's all I use posix for. I do catch some signals to shutdown cleanly, but that's really not a requirement, just being polite. Tellme is set to re-build a raw hosts file on each new startup (via setting $changed to 1 at init), so it doesn't have to shut down clean.

The other possible issue is the format of the usual hosts file, which is hardcoded into the program tellme. That might have to change on some systems (windows, or non-ipv6 linuxes). I have what was the normal hosts format as data in the program as it sits - so I could put the new stuff after the loobacks and before the ipv6 junk, just as the system likes.

Here's what my default hosts file looks like either before installing any of this, or after running awhile with nothing else on the LAN:
Code: Select all
127.0.0.1   localhost
127.0.1.1   main

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


I hardcode the first two lines, then add whatever between them and the hardcoded ipv6 lines when writing to the file - all kept in one scalar in perl (would be a string in C). That could probably be improved, but every hosts file I've seen on any version of linux here looks like this. Even though I also know the LAN IP of "main" in the tellme of "main" (this machine), I don't add that, since it's slower for main to get to itself that way than via 127.0.1.1 or 127.0.0.1. EG tellme is smart enough to know it's me hearing my own broadcast and not to include that in the hosts file.

Here's what that file looks like a few seconds after turning on two more machines on the LAN:
Code: Select all
127.0.0.1   localhost
127.0.1.1   main
192.168.1.4   fusor2
192.168.1.12   server

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


Two minutes after turning them off (more or less), the file reverts to the original. That's a hardcoded number of seconds which seemed about right.
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.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: DNS for my LAN

Postby Doug Coulter » Sat Feb 02, 2013 8:01 pm

OK, finally a version I'm really happy with for this. The zip now contains and installer script (you'll probably have to make it executable after unzipping), and a readme that tells you all that kind of thing and how to do most of it (feedback appreciated).

landnsV97.zip
Version that works - automated install
(6.42 KiB) Downloaded 494 times


Basic use:
Get this zip. unzip it, it will create a subdir. There you will find a readme file - read it.
Depending on your distro, you may have to mark the install script (named LanDNS) as an executable.

Get a terminal. cd to wherever the files are unzipped to - unzipping will make a subdir of wherever the .zip was called landns that will have all the files.

Then say sudo LanDNS and enter. You must be "root" to install this stuff to system directories and have it run as root.

The next time you run (this stuff is only run on a reboot), you should be able to find tellem and tellme as processes if you set your preferences to "all processes" in the system monitor app, rather than just "my processes". This is because all this stuff is started at startup and running as root in the background. Once you've got these working, you can delete the zip and the files - the installer puts them in system directories, makes them root and executable for you before it exits - you no longer need these files wherever you unzipped them to.

Once you have it running on more than one machine, try cat /etc/hosts, and now you should see any other machine that is running these on your LAN, and they should see you.

Changes:

tellem no longer tries to write a logfile - that was failing sometimes. It now also does it's sleep first in the loop - it turns out that it was getting started too soon in the boot process for things like DHCP to have completed, and was dying when it couldn't get an IP at that time. Sleeping for about a minute - everything is good (you don't have to have logged into the machine for these to work!).

Tellem is now also autostarted a different way, not in "startup applications" anymore, which wasn't for some reason, reliable - probably the bug noted above.
Now it's all uniform, pretty, and according to the rules.
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.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: DNS for my LAN

Postby Doug Coulter » Wed Feb 19, 2014 8:51 pm

Wasn't sure where this fit, but I now have tellem working on all manner of things. The existing code above works fine on a raspberry pi, more or less unchanged other than how you get it started (I used init.d for the pi). I've now also done a "sketch" for a chipkit uno32 (kind of a big brother to the stock arduino uno) with wireless. That took C++ code since no way it'll run things like perl.

And for now, it only goes one direction - the tiny guy just announces himself to my LAN. Since the tiny guys are intended to be remote data aq (think "is my water system going to freeze, or what's the weather?" type of thing, and produce a web page - they don't "need to know", eg run tellme, about the rest of the LAN anyhow. They are in essence, pure slaves.

The object is going to be to set up the pi as an always-on server for the entire place - it's wired ethernet itself. Then have a bunch of little guys around that can sense things and report to a mysql database on the pi, which I can then mine from a "real" PC, and in fact, setup data duping automatically, so anytime any pc here with mysql on it runs, it'll sync with whatever the pi has. All for a couple of watts. Even off the grid solar can allow for that to be on 24/7 - I save that much by putting in more efficient led nightlights. The old tech ones drew 20W or so (lots of them, lumina light engines). The new ones? 5w at full brightness, about 3x brighter than the old. So I'll dim them down and get to about 3W.

You might think a pi can't do this, but soon to come (definitely on the embedded subforum) is how I got it to do all this, and support a 128 gb hard drive in the process. It only boots from the flash card now - the rest goes on the big (for this) SSD drive. In a funny mismatch of tech - the sata->USB converter chip in the external drive caddy is the thing that draws the most power in the whole setup - more than either the pi or the disk drive itself...funny old world, eh? For those who don't know - remote desktop into the pi is a piece of cake, so once youve got it basically going, you don't need a keyboard and screen on it - you can remote from any other machine into it and have your own X session in a window on a PC for example.
This means I don't have to buy those things, or use up the ports, or put it in a place that's easy to get to.

I'll be putting my sketch up for all this in the embedded thread when it's a little further along - it's already web-serving, but it serves test/debug junk now. I'll be converting to the next larger chipkit thing anyway, as soon as it gets here - more bang for the buck, and the wireless ethernet is built in, rather than being an expensive add-on. In the meantime, I'm developing (and running out of ram on) the uno32, shown here:
http://www.digilentinc.com/Products/Det ... PKIT-UNO32

Really nice stuff, if not as cheap as an arduino clone from china... and I'm moving to this:
http://www.digilentinc.com/Products/Det ... IPKIT-WF32

This thing also supports USB OTG, which means I can slave a regular arduino uno off it....should I need more i/o. It has plenty by itself, but you never know.


Believe it or not, on the raspberry pi forums, I got a ton of crap for sharing how I do this lan dns stuff - they say writing to /etc/hosts is so '70s. Yeah, like I can run bind on an arduino.
Even a pi with much more resorces kind of chokes on things like that. It's the simplicity of the protocol that is important here - even a regular arduino can do the C++ version of tellem...but don't try running bind or a database on one....This protocol can run on anything, though it'd probably need a little bit different code for windows (which does have a hosts file). No need for a situation where everyone can't find everyone else due to (non) competitive (non) cooperation between the opsys makers. Now all my little stuff can be found by all the big stuff - without resorting to scanning whole net IP spaces all the time and guessing where things are - even when they are all on DHCP as they are here.

Even if it is me saying it, I'm calling this project/vision a win.
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.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: DNS for my LAN

Postby David Ashley » Thu Mar 06, 2014 8:47 pm

Doug Coulter wrote:Actually, yes, tellem would be super nice ...

Ah, like on normal linux, /etc/hosts in android is a root-owned file....crap.


I have one of these:
http://www.synology.com/en-us/products/overview/DS413j

It is an always-on ARM linux system that can take up to 2 SATA drives and act as a file server. I installed a dhcpd server and I've manually edited the dhcpd.conf file so it will spit out static IP addresses based on the MAC address of the client.

If you have anything on your setup that is always on and you can install dhcpd you can do the same. Then you don't need to worry about /etc/hosts and the root requirement. I'm sure the raspberry pi could do it. You'd want to turn off the dhcpd service on your WAN router. But maybe that's not possible. Your life would probably get a lot easier if you had a router under your own control in between.

Meanwhile I'll see about writing that tellem app on android. Maybe later this evening...
User avatar
David Ashley
 
Posts: 12
Joined: Thu Mar 06, 2014 2:42 pm
Location: Houston, Texas

Re: DNS for my LAN

Postby Doug Coulter » Thu Mar 06, 2014 9:15 pm

Good advice. Sad thing is I can't mess with the telco router at all (and the doggone thing is a power hog on top) - they already blame their problems on me and know that I *could* hack their stuff (you should see their jaws drop when they come into the computer room here). I can work one standard linux box into this, always on, if it's a really low power one. That's it. The reason for the other guys is distance - wires would be long, a PITA to bury, and pick up noise and the EM from lightning all too well, and I have small signals to digitize for this. I was looking at the pi for that, but it's very very slow with any "real" software. Even their web browser slashdots itself just sitting there with static content, swapping memory and thrashing at 85% cpu. Yeah, I know most everything I need here takes less than even Midori, but hey - it does add up when you have a lotta little daemons going.

I'm trying to squeeze this entire data logging project into about 25 watts, which I'm saving by replacing some real old led "lumina light engines" with newer stuff. Being off-grid can be a hassle that way - that's an amp off my 24v batteries. On a bad sun day, extra always-on loads mean I have to go out and put gas into and run a generator. I'm trying to keep below that threshold for that reason - if it could handle the 40w I was using for night lights (it's a big campus), then it should hack this after I remove 15w of other waste in old, inefficient leds and put in the new guys (I might save more power than that, I'm being conservative here). Old leds - 1 amp at 12v. New ones, 160ma at 12v. Lots of them...and the new ones are also brighter - I could even run them a little on the lean side and still have enough light.
Not that any of my inverters have yet failed, ever, but I'm planning to run all this off tiny "simple switchers" right off the main battery bank since some of this data is important, and that should be more efficient than going through an inverter and then down-switching again (mayhaps even with a transformer and its core losses).

Yeah, if I could run an intel NUC (I might, but the price is a little off-putting) - perhaps the i3 version - then it would be a lot easier to just use the off the shelf stuff, software wise, that'd definitely be fast enough -and leave power left for the chipkit wf32s and arduinos that are doing the aquisition - about 8 channels each at various speeds - maybe 3x of them. One app makes a line of 9 numbers (time and 8 data channels) at 10hz, but most of the other ones can be slower than that. I do need about 1 hz for the solar insolation sensors and wind gusts, earth's mag field in 3 axes (hey, I'm wanting it all!). I really want to see what's available instantly, the one thing my otherwise fine Xantrex system won't tell me - it just tells me what I'm using, or what it's now putting out, not what it *could* put out - the only way to discover that now is to turn things on till the solar amps stop going up and the battery volts start going down, it's a PITA. I'll have to just use a fully loaded tiny solar cell and an a/d channel to find out how bright the sun is right now (which time-series is also a weather indicator - how big/fast moving are the clouds), at the angle my big panels are at, and figure out the constant to know what there is available.

Which leads to another low level very tricky issue (yeah, a little OT). All the Xantrex stuff uses CAN bus - in a proprietary format, and publish-subscribe and can't handle more than 4 charge controllers, one inverter, and the control panel. I have 5 charge controllers and a Xanbus to wifi converter, but I can't use them connected. Plug in one more thing and the collisions kill it - they were too dumb to have a random back-off time when there's a bus collision (like ethernet), so I'm about to think about how I might do a "switch" or "store and forward" thingie for can bus...I wonder if anyone else needs that as product, or if I should just live with it as is. Seems like hard enough work not to bother if I can't find a few others who want one.
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.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: DNS for my LAN

Postby David Ashley » Fri Mar 07, 2014 2:53 am

David Ashley wrote:Meanwhile I'll see about writing that tellem app on android. Maybe later this evening...


Here's a first pass. Inside ace_tellem.zip is ace_tellem.apk (for some reason phpbb wouldn't let me upload a .apk file). Unzip, recover the .apk file, and install it.

I started with my ace-thatwaseasy codebase here:
http://code.google.com/p/ace-thatwaseasy/

then just added the udp network broadcast code. It sends out every 30 seconds a udp message like this:
192.168.10.5 android1
to broadcast port 53831 (255.255.255.255:53831)
The name "android1" is hardcoded for now.

If you hit the "back" button the program will exit. But if you hit "home" it will be left running in the background.

Let me know if it works at all. I can make the source available also. I'm not sure how to deal with the hostname better...

ETA: I added ace-tellem.tgz which is the source. Some paths would have to be tweaked (like references to /home/dash). Also only building with "ant debug" will likely work as my signature process won't work for anyone else.
Attachments
ace-tellem.tgz
(171.2 KiB) Downloaded 420 times
ace_tellem.zip
(164.5 KiB) Downloaded 418 times
User avatar
David Ashley
 
Posts: 12
Joined: Thu Mar 06, 2014 2:42 pm
Location: Houston, Texas

Re: DNS for my LAN

Postby Doug Coulter » Fri Mar 07, 2014 5:26 pm

Well, that was quick, I'll see about trying it real soon now. Still swamped with email filtering from that 15 min of fame thing. I'd long ago put my Nexus into developer mode, so I should be able to get that in there? Heck, it's been so long I'm going to have to look up how to do it again (I'll do it, no problem). My own first try, their example of "hello world" kinda upset me, is all - several hundred K bytes to make a full, blank screen with hello world on it in 6 pt type? You gotta be kidding!
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.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: DNS for my LAN

Postby David Ashley » Fri Mar 07, 2014 6:13 pm

Doug Coulter wrote:Well, that was quick, I'll see about trying it real soon now.

No urgency, it really wasn't much trouble at all. To install an apk file directly all you've got to do is navigate to it with a file browser. I use ES File Explorer and a LAN shared volume. No need to gear up for development just to see if the thing works.

Actually just dusting off my setup to be able to do android coding was worth doing, I appreciate your giving me an excuse to do it. Motivation is the biggest problem these days...
User avatar
David Ashley
 
Posts: 12
Joined: Thu Mar 06, 2014 2:42 pm
Location: Houston, Texas

PreviousNext

Return to PC

Who is online

Users browsing this forum: No registered users and 1 guest

cron