[svlug] "Mini-DNS" - gethosts

Rafael raffi at ark.linwin.com
Mon Jan 21 13:19:01 PST 2002


On Mon, Jan 21, 2002 at 03:08:32PM -0500, Gyzmobro at aol.com wrote:
> hello. on my home network, i've setup a linux box to run DHCP to assingn 
> fixed ip numbers based on a client's MAC address. i haven't been able to get 
> DNS running, and i don't think i'd like to do that now anyway. 

Run DNS, that's why it was invented in the first place. DNS setup is not
that hard. There are many tools to do it automaticaly. Worst case use 
webmin.

Why bother with distributing hosts files? Your systems will be so much out
of sync you won't believe.

> 
> what i'd like to do is write a bash shell script for all the linux DHCP 
> clients that would connect to the DHCP server at boot and get a file in the 
> format of /etc/hosts, created seperately by me on the server, with all the 

That's easy. Append a hosts file from NFS server (hosts has to be
exported, /share/hosts for example) to /etc/hosts. All you need to do is
create hosts entries on NFS server if that's the way you want to go.  You
can periodicaly check to make sure it's up to date. No passwords etc. 
needed.

For other purposes when you need to interact with other programs like 
logins etc. use expect. Be aware of security implications though.

> fixed hosts and ip numbers in it that DHCP assigns. the script then would 
> then compare an area of /etc/hosts on the client with the file it pulled from 
> the server, and append all the entries that are in the downloaded file to 
> /etc/hosts, so the client would know the ip numbers of all the linux boxes on 
> the network. if something changes and the script is executed, /etc/hosts 
> should be updated. so that nothing is messed up, i wan't to script to 
> designate an area in the file where it will make all it's changes, and leave 
> anything that was previously there alone. so basically you would have 
> something like this:
> 
> # do not remove the line below or some programs won't work...etc
> 127.0.0.1       localhost.localdomain   localhost
> 192.168.0.1     hosta.home.net          hosta
> 
> #^#^#^#^#^#^#^#^#^#
> # Start of gethosts configuration.
> 
> 192.168.0.2     hostb.home.net          hostb
> 192.168.0.3     hostc.home.net          hostc
> 
> # End of gethosts configuration.
> #^#^#^#^#^#^#^#^#^#
> 
> in between the #^#^#^#^#^#^#^#^#^#^# and # star/end... is where i wan't all 
> the changes to be made from the script.
> 
> my problem is, i don't know how i would tell the script to ftp, for example, 
> to the server and put in a password, get the file, and logout. i'd also like 
> to know some easy to use file comparison utilities.
> 
> thanks in advance,
> 
> serban giuroiu (the kid at the installfest)
> 

-- 
Rafael




More information about the Svlug mailing list