Mounting Network Drives with users at home?

KCH080208
New Contributor II

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 6

mm2270
Legendary Contributor III

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
Release Candidate Programs Tester

@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
Honored Contributor II
Honored Contributor II

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
Contributor II

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

KCH080208
New Contributor II

@davidacland do you have an example of this?

davidacland
Honored Contributor II
Honored Contributor II

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