Skip to main content
Question

Mounting Network Drives with users at home?

  • November 24, 2014
  • 6 replies
  • 32 views

Forum|alt.badge.img+5

Is there a way for when a user goes home that the script i have to mount network drives does not run because it doesn't see our directory? I am sure there is a check that can be done but not being script savvy am not sure how to write it. Any information would be greatly appreciated.

6 replies

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • November 24, 2014

What language is the script written in?
Whichever it is, there are probably a dozen different ways you can address this. A common way would be to pick some internal only domain controller or server or something and do a ping or ncat or nslookup against it first in your script and then based on the results, move on to mounting the shares or just exit silently. IOW, if your script can see the internal servers or DCs, it can likely mount the shares. If not, no point in even continuing, so just exit.


bentoms
Forum|alt.badge.img+35
  • Hall of Fame
  • November 24, 2014

@KCH080208, as @mm2270 said.. There are many ways.

Really depends on your script, to help we'll need to see it.

FWIW, we map drives based on AD group membership... When off the domain, clients cannot see the domain & therefore cannot get membership. So nothing tries to map.


davidacland
Forum|alt.badge.img+18
  • Valued Contributor
  • November 24, 2014

If the script is being triggered by a policy you could just restrict it to a specific network segment (or segments).

Failing that I would use a ping check on a known internal server.


jescala
Forum|alt.badge.img+12
  • Contributor
  • November 25, 2014

Instead of using a script to mount network shares, try using autofs. That works well to disconnect and reconnect network shares as needed.


Forum|alt.badge.img+5
  • Author
  • Contributor
  • May 4, 2016

@davidacland do you have an example of this?


davidacland
Forum|alt.badge.img+18
  • Valued Contributor
  • May 4, 2016

@KCH080208

In your JSS, go to Settings > Network Organisation > Network Segments and add the IP range of your local network.

Then in the policy, go to Scope > Limitations > Add and add the network segment.

If you want to include a ping check into the script instead (or as an added safety measure), here's some code you can use:

PingServer="your.server.com"    # The address of a server on your local network that responds to a ping

ping -c 3 $PingServer &> /dev/null

if [ $? == 0 ] ; then 
        exit 0
    else
        # do the rest of your drive mounting code here
fi

The only downside with the ping method is if someone removes the ping server, the script will stop mounting the network drive as it will think it's off the network.