Operating System - HP-UX
1834355 Members
2773 Online
110066 Solutions
New Discussion

Script to update /etc/hosts automaticaly

 
Paulo Alexandre Teixeir_1
Occasional Contributor

Script to update /etc/hosts automaticaly

I must create a script to update all hosts files from my servers. I do not want to use NIS. Someone allredy do'it?
5 REPLIES 5
Peter Godron
Honored Contributor

Re: Script to update /etc/hosts automaticaly

Paulo,
have you got rhosts set up? If so, rcp the file.
If not, can you not use ftp to put the file?
Christian Tremblay
Trusted Contributor

Re: Script to update /etc/hosts automaticaly

.rhosts is not secure and probihited at many sites.

If you want to distribute a master host files to your servers it would be better to use scp.

Provided you have deployed your ssh keys on all servers, this line would do it:

for i in `< serverlist.txt`;do scp -p /etc/hosts $i:/etc/;done

serverlist.txt being a simple file containing your servers names.

If you did not deploy your ssh keys, it will still work but you will have to provide the password for every server when asked.
Ninad_1
Honored Contributor

Re: Script to update /etc/hosts automaticaly

Hi Paulo,

You can either use rcp/scp if been setup on all the servers.
Another thing is are you going to treat a particular server as a master server which will distribute the hosts file - this will help you in having a single source to update, so that if any server is unavailable at a particular time - the next time you distribute or if you distribute once the server is up consistent file will be there across hosts - rather than allowing from any host to all hosts.

regards,
Ninad
Steven E. Protter
Exalted Contributor

Re: Script to update /etc/hosts automaticaly

Shalom Paulo,

I recommend setting up password free insfrastructure on ssh/scp and distributing the host files that way.

/etc/hosts deals with Internet DNS names resolution. NIS really doesn't. What NIS provides is that one login works on many servers, saving you a headache in administrering passwords.

A more modern solution to the user management issue is LDAP or integration with a Windows based ADS server. Samba can also be integreted toa Primary domain controller or become a Primary Domain Controller itself.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
harry d brown jr
Honored Contributor

Re: Script to update /etc/hosts automaticaly

If you have a DNS server, then don't bother with updating the /etc/hosts file omn every server, simply set up your servers to do DNS caching:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=840826
(see my posts to this).

live free or die
harry d brown jr
Live Free or Die