Profiles Switcher › Blog

How to Run Automations When Your Mac Connects to a VPN

By the Profiles Switcher team. Published .

To make your Mac do something when a VPN or wired network connects, add a "Network service active" rule to a Profiles Switcher profile, pick the VPN or network from the list, and add the actions to run: mount a share, set a printer, open your intranet or run a Shortcut. The profile turns on as soon as the connection has an IP address, and your other profiles take over again when it disconnects.

Active while the company VPN is connected, from home, a café or a hotel.

Set this up with Profiles Switcher on the Mac App Store, or start from a ready-made recipe.

What does the Network service trigger do?

It watches your Mac’s network connections and turns a profile on while the connection you picked is up and has an IP address, which is the moment it is ready to use. It sees three kinds of connections:

The list shows each entry with what it is and whether it is connected, for example Tailscale · VPN · Not connected or utun7 · 10.8.0.4 · Tunnelblick (WorkVPN).

How do you set it up?

  1. Click the Profiles Switcher icon in the menu bar, choose Preferences… and create a profile, for example Work VPN.
  2. Click Add Rule…, choose Network service active and pick your VPN or network. Using a VPN app such as Tunnelblick? Connect it first, and its tunnel shows up in the list right away.
  3. Click Add Action… and add what should happen: mount a share, set a printer, open a URL, run a Shortcut.
  4. That is it. The next time the VPN connects, the profile switches on by itself, and the menu bar shows it as the active profile.

The rule needs no permission, and it follows the service even if you rename it later in System Settings.

What can you automate when the VPN connects?

A VPN usually means “I am working now”, which makes it a great signal for a work setup wherever you are:

Which entry should you pick?

Pick the entry that matches how your VPN or network connects. VPNs set up in System Settings are listed by name, VPN apps show their tunnel, and docks show their Ethernet adapter:

Your connectionPick in the list
A VPN in System Settings > VPN (Tailscale, IKEv2, IPSec)The VPN by name under Services
A VPN app with its own tunnel (Tunnelblick, Windscribe)Its tunnel under Tunnels, or an IP address / range rule on the VPN’s address range
A dock or Thunderbolt Ethernet adapterThe adapter, for example Ethernet Adapter (en5)
Your iPhone over USBiPhone USB

For a VPN app, the IP address / range rule is the most durable choice: a Tunnelblick connection that always hands out addresses in 10.8.0.0/24 matches that range every time it connects.

How is it different from the Ethernet and IP address triggers?

Three triggers watch your network, each at a different moment:

Can you combine it with other rules?

Yes. Set the profile to All are true and add more rules. For example, the VPN plus an external display makes a “Remote desk” profile that only switches on when you are connected to work and sitting at your big screen. With Any is true, the profile turns on when either the VPN or your office Wi-Fi is connected, so the same work setup follows you from the office to home. Exactly one profile is active at a time, and its priority decides which one wins when several match.

Frequently asked questions

Does the Network service trigger need a permission?

No. It reads the connection state that macOS shares with every app, so there is nothing to allow. Only Wi-Fi network rules need Location access, because macOS treats the Wi-Fi name as location data.

What happens if I rename my VPN in System Settings?

The rule keeps working. It remembers the service itself, not just its name, so a rename in System Settings changes nothing.

Where do VPN apps like Tunnelblick show up?

Under Tunnels in the rule's list, as soon as the VPN connects. Each tunnel shows its address, and Tunnelblick tunnels also show the name of your configuration, for example utun7 · 10.8.0.4 · Tunnelblick (WorkVPN).

What are the utun entries in the list?

Tunnels: virtual network interfaces that VPN apps create when they connect. macOS runs a few of its own for system services; those carry only a link-local address and are labelled "likely a macOS system tunnel".

Ready-made automations for this

vpnhome-and-officehow-to

Let your Mac switch its own setup

Profiles Switcher is a menu bar app for Mac (macOS 13 or later, Apple Silicon and Intel) that switches your Mac's setup automatically. You build profiles from 19 triggers, such as the Wi-Fi network you join, a place, headphones or a display, and 18 actions, including running any of your Shortcuts. Everything runs on your Mac; it is available on the Mac App Store.

Download on the Mac App Store