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.

link|improve this question

77% accept rate
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. – Shadow Jan 18 '11 at 18:06
1  
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
feedback

1 Answer

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

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

Your Answer

 
or
required, but never shown

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