0

I'm trying to create a .mobileconfig to VPN auto connect to an L2TP VPN server of mine. The problem is, if I enabled the "on demand" settings, the macOS keeps trying to connect over and over and never connects. The same script on iOS works flawlessly.

macOS: Mojave

iOS: 12.2.1

Logs: the file /var/log/ppp.log does not show connect attempts when it's on "on demand" mode.

Here is my script:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>PayloadContent</key>
  <array>
    <dict>
      <key>UserDefinedName</key>
      <string>Home: WiFi</string>
      <key>PayloadDisplayName</key>
      <string>Home: WiFi</string>
      <key>PayloadIdentifier</key>
      <string>com.idetifier.vpn</string>
      <key>PayloadUUID</key>
      <string>***********************************</string>
      <key>VPNType</key>
      <string>L2TP</string>
      <key>IPSec</key>
      <dict>
        <key>AuthenticationMethod</key>
        <string>SharedSecret</string>
        <key>LocalIdentifierType</key>
        <string>KeyID</string>
        <key>SharedSecret</key>
        <string>****************</string>
      </dict>
      <key>PPP</key>
      <dict>
        <key>AuthName</key>
        <string>**********</string>
        <key>AuthPassword</key>
        <string>************</string>
        <key>CommRemoteAddress</key>
        <string>***********</string>
      </dict>
      <key>OnDemandEnabled</key>
      <integer>1</integer>
      <key>OnDemandRules</key>
      <array>
        <dict>
          <key>InterfaceTypeMatch</key>
          <string>WiFi</string>
          <key>SSIDMatch</key>
          <array>
            <string>*********</string>
          </array>
          <key>Action</key>
          <string>Disconnect</string>
        </dict>
        <dict>
          <key>InterfaceTypeMatch</key>
          <string>WiFi</string>
          <key>Action</key>
          <string>Connect</string>
        </dict>
        <dict>
          <!-- VPN Default state -->
          <key>Action</key>
          <string>Disconnect</string>
        </dict>
      </array>
      <key>OverridePrimary</key>
      <true/>
      <key>IPv4</key>
      <dict>
        <key>OverridePrimary</key>
        <integer>1</integer>
      </dict>
      <key>PayloadType</key>
      <string>com.apple.vpn.managed</string>
      <key>PayloadVersion</key>
      <integer>1</integer>
    </dict>
  </array>
  <key>PayloadDisplayName</key>
  <string>**************</string>
  <key>PayloadIdentifier</key>
  <string>************************</string>
  <key>PayloadRemovalDisallowed</key>
  <false/>
  <key>PayloadType</key>
  <string>Configuration</string>
  <key>PayloadUUID</key>
  <string>********************</string>
  <key>PayloadVersion</key>
  <integer>1</integer>
</dict>
</plist>

If I remove those lines below, the script works normally on macOS (but I have to manually connect).

<key>OnDemandEnabled</key>
      <integer>1</integer>
      <key>OnDemandRules</key>
      <array>
        <dict>
          <key>InterfaceTypeMatch</key>
          <string>WiFi</string>
          <key>SSIDMatch</key>
          <array>
            <string>*********</string>
          </array>
          <key>Action</key>
          <string>Disconnect</string>
        </dict>
        <dict>
          <key>InterfaceTypeMatch</key>
          <string>WiFi</string>
          <key>Action</key>
          <string>Connect</string>
        </dict>
        <dict>
          <!-- VPN Default state -->
          <key>Action</key>
          <string>Disconnect</string>
        </dict>
      </array>

What am I doing wrong?

You must log in to answer this question.

Browse other questions tagged .