Mounting Network Drives with users at home?

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.


Legendary Contributor II

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.

Honored Contributor III
Honored Contributor III

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

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.

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.

New Contributor II

@davidacland do you have an example of this?

Honored Contributor II
Honored Contributor II


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=""    # 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
        # do the rest of your drive mounting code here

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.