Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm setting up a couple of Windows laptops to mount home directories from our file server. The file server uses NFS for Linux clients and I've set up Samba for these Windows clients. At startup, I'd like them to mount using Samba when on the LAN and a secure FTP connection otherwise. I'm confident the rest can be scripted or otherwise (I have some C# experience, so if batch files are insufficient, I can write a more complex C# program), I just don't know how to approach determining whether or not the computer is on the LAN.

share|improve this question
Well, how do you define "on the LAN"? ipconfig shows same subnet as your office LAN? Active Directory/kerberos authentication successful? – gravyface Jan 18 '11 at 17:51
For laptops, I would probably define it as having an IP address issued by my DHCP server. Wasn't aware there was much debate on the topic. – Alex S Jan 18 '11 at 18:06
Since the point of your script is to mount something from a file server, why not just attempt to ping the fileserver, or attempt to connect. If it fails, the network wasn't up. – Zoredache Jan 18 '11 at 18:11
what happens if they're on the same subnet as your office? I like Zoredache's suggestion actually: because if for some other reason they can't connect (i.e. on the same subnet as your office), they can always connect through the Internet and SFTP. – gravyface Jan 18 '11 at 18:47

How about running an IPCONFIG /ALL and seeing if the DHCP server listed is one of your expected 'on LAN' servers?

share|improve this answer
+1 for the obvious. – John Gardeniers Jan 18 '11 at 20:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.