Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Share:
Notifications
Clear all

[Solved] How do I auto-mount a share only when VPN (Wireguard) is connected?

3 Posts
2 Users
1 Likes
643 Views
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

Hey Hans,

 

I was wondering if you could help me out and think of ways I might be able to do this, with how the program works behind the scenes. I have some shares on an office NAS I connect to over SMB. I've set these up to auto-mount in CMN when I'm on a specific network router (ie home wifi or ethernet), from the gateway MAC address.

 

I was wondering if you thought it was possible to auto-mount the shares when I'm using this Wireguard VPN in the wild (ie not on my home network)? If so, how would I go about it?

 

Thanks!


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2678
 

Hey there! 

Interesting question - and great application!

Not knowing how IP ranges and such are set for your Wireguard connection, one could try how well this works when using "On network change" (disable "On server IP address appear" and disable "but only only if default gateway mac is"). So whenever your network changes, and the share is not mounted yet, it will try to mount said share, even if it's not a suitable network.
Note: This under the assumption that enabling Wireguard, will trigger a system wide "network change" event (and I think macOS does, just when using a regular VPN, etc).

Of course you can combine this with "On server IP address appear", but that would be polling for the server every so many seconds, where as "on network change" is a macOS event (no polling needed, macOS will tell ConnectMeNow).

Let me know if that worked, otherwise I'll see and try to find a solution that works for you 😊 


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

Actually, now that I've thought about this some more, I think the functionality is already there. Cause yes, I could auto-mount the shares based on "network change" event, which would only actually mount them if it could connect to the WG VPN, because I also have a "ping before mount" option enabled. When WG VPN isn't running it cant reach that IP address and would just fail anyway.

I'll reach back out if there's issues with this while I'm testing it remotely over the next little bit.

 

Thanks Hans!


   
Hans reacted
ReplyQuote
Share: