Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 06-16-2011, 04:56 PM   #1
Registered: Dec 2003
Posts: 78

Rep: Reputation: 1
Synchronizing /etc/hosts files across multiple servers


I have 16 linux servers that use /etc/hosts files to see and talk with each other. I'm adding servers to this pool of servers.

It is required to do host resolution via the /etc/hosts files. DNS or NIS are not alternatives.

Aside from manually editing each of the 16+ /etc/hosts files every time I add a server or editing one /etc/hosts file on one server then scp'ing it to all the other servers, is there anyway to edit the /etc/hosts on one server and "push" it onto the other servers that need the new /etc/hosts file?

Everywhere I've looked on the Net, there hasn't been any suggestion except for the options I mention here.

Or am I just whistling in the wind?

Thanks for your time and consideration.

Blaine Miller
Old 06-16-2011, 05:18 PM   #2
LQ Guru
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
I can't say I get the difference between using SCP to transfer the files to the destination servers and "pushing" it. What would you consider pushing to the remote machines if not transfering the file?

If it is an issue of effort, it would be no problem to script the SCP action so that it is done automatically without having to run the command 16 times.
Old 06-16-2011, 05:23 PM   #3
Senior Member
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi Blaine,

You can try this:

Pretty similar to scp'ing way you mentioned.

I am not aware of any other way of synchronizing /etc/hosts other then the above mentioned two methods.

You can create a cron job to run every hour on the source server to push updated /etc/hosts file to destination server.
Old 06-16-2011, 05:42 PM   #4
Registered: Dec 2003
Posts: 78

Original Poster
Rep: Reputation: 1
Great! Thanks, T3RM1NVT0R...

I agree about the solution presented on the site you included with your post. It is pretty similar to scp'ing the file over.

And I was afraid you'd say that about there not really being any other way to make changes to the /etc/hosts file propagate out to the other servers.

This really was a problem fixed when DNS was created. I'm lobbying for adding DNS resolution myself, but our Dev Director won't approve it till it's been tested.


I'll mark this as solved and closed...

Old 06-16-2011, 07:44 PM   #5
Senior Member
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,124

Rep: Reputation: 780Reputation: 780Reputation: 780Reputation: 780Reputation: 780Reputation: 780Reputation: 780
but our Dev Director won't approve it till it's been tested.
Until DNS solution over a hosts file has been tested? Tell your Director to read the history of the Internet. DNS (BIND) was invented because managing hosts files became unmanageable over multiple hosts. Do they have a particular hang up or question that we might be able to help address? DNS was designed for this very purpose.

In the mean time, I might suggest putting the master host file in a centralized location and then creating a cron task to synchronize among the various hosts. SCP would work, as would rsync. By setting it up as a cron task, you would guarantee that updates were propagated regularly. Given the what I presume to be the limited (small) size of the hosts file, you could even have it synchronize often without ill effect to your network.
Old 06-20-2011, 06:32 PM   #6
Registered: Dec 2003
Posts: 78

Original Poster
Rep: Reputation: 1
I agree about the Dev Director... He's pretty lame... But I'm just the flunky that has to find some way of implementing things he proposes we do in his lame way.

I like the idea of syncing the files from a central location with a crontab entry. I'm going to keep the suggestion under my hat in case my *grand scheme* fails. That scheme being to force this lame Director into good practices, like using the right tools for the job, like using DNS for the purpose it's meant to be used for.

Like I said, I do well appreciate your well meant question. Your alternative is very elegant.

Old 06-23-2011, 01:05 AM   #7
Registered: Jul 2009
Location: /
Distribution: centos
Posts: 47

Rep: Reputation: 1
you can use drbd for that !


hosts, resolve

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Synchronizing 2 servers bucovaina78 Linux - Server 4 09-07-2010 06:20 AM
Multiple hosts not seeing each others files even though LUN is same abylin1 Red Hat 1 01-11-2008 08:46 AM
Multiple addressing through hosts files Slick666 Linux - Networking 3 07-25-2006 10:10 AM
Synchronizing Users Across Multiple Servers ghight Linux - Networking 4 08-22-2003 10:35 AM
Software for synchronizing files on web servers josephswagner Linux - Software 2 02-06-2003 01:13 AM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:23 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration