script that will copy a hosts file

I need a script that will copy a hosts file I maintain on my Linux (SAMBA PDC) server to my XP clients. Instead of reinventing I'm just looking to see if anyone has already done this and if so could send me the .bat file.

mkelly@infinitybluewater.com
infinityitAsked:
Who is Participating?
 
guruyayaCommented:
I have to disagree that DNS is a good way to solve this problem. First, it`s a service that was crackers favorite for some time in the past. It`s better nowdays, yet it is a service meant for bigger, more complex networks. Yet host file coppying should be quite a mess. I`ve solved the problem, using samba. Just by adding thease lines

wins support = yes
name resolve order = wins hosts lmhosts bcast

Will  enable you to read the contant of the hosts file on every XP computer on the net.
0
 
pjedmondCommented:
Just add the following line to the logon.bat file:

copy N:\hosts C:\windows\hosts

There are a couple of problems here in that the user copying the file must have administrative rights to do this, and also windows XP home, and professional seem to use the aforementioned direcory, and C:\WINNT...so if someone would like to expand on the concept.

You need to have created the samba share:
-------------------------------
[ netlogon]
  comment = Network Logon Share
  path = /home/netlogon
  guest ok = yes
  writable = no
  share modes = no
  browseable = no
--------------------------------

Note that this is the samba 3.x version.

HTH:)
0
 
infinityitAuthor Commented:
HTH,
The command
copy N:\hosts C:\windows\hosts

looks to me like it's copying from a windows mapped drive (N:) to the windows system drive.

My hosts file will be in /home/netlogon on the Samba server and from there I want the script to copy the file to the Windows system drive (which is actually c:\windows\system32\drivers\etc)

My [netlogon] in smb.conf is exactly as you've written.
Thanks,
Mark
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
ryanhuntCommented:
Why don't you just setup a DNS (bind, djbdns) server on the Linux box, and add the linux box as a secondary (or tertiary) to the windows machines? It'll be much easier in the long run. It'll also get you around the problems of the users needing to be Administrator etc etc.

I guess you want the login script to look like this:

net use N: \\sambaserver\netlogon
copy N:\hosts c:\windows\system32\drivers\etc

also you'd want to add a cron job on the linux box that copys the /etc/hosts file to one in the /home/netlogon folder (using the example above)

Ryan.
0
 
infinityitAuthor Commented:
The DNS idea sounds like a good one. Do you know of a resource I can refer to that will guide me through that process?
Thanks,
Mark
0
 
guruyayaCommented:
Oh, one more thing

If you wish to enbale a DNS after all, a good guide is
http://tldp.org/HOWTO/DNS-HOWTO.html

Have a nice day
0
 
infinityitAuthor Commented:
OK I already have "wins support = yes" in my conf file. If I follow it with "name resolve order = wins hosts lmhosts bcast" does that mean every XP box on my network will use the hosts file on the Samba box after it tries wins to resolve providing the XP boxes use wins?
0
 
guruyayaCommented:
I belive so. And I`m quite sure that trying it won`t blow any computer :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.