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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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:)
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
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.
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
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?
guruyayaCommented:
I belive so. And I`m quite sure that trying it won`t blow any computer :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Networking

From novice to tech pro — start learning today.