How to Setup a L2TP VPN Server on OS X

This is a fast guide on configuring OS X to act as an L2TP VPN Server. This can be accomplished with Apple’s Server App, but if you don’t mind running a few Terminal commands and adding a couple configuration files manually, you can save yourself $20 and go out to eat instead.

This guide also includes a workaround for a known bug in the general release of OS X 10.9 Mavericks in its implementation of racoon that prevents remote clients from being able to connect to your VPN server.


Estimated Time Required: 10-15 minutes
Tested on: OS X 10.8 Mountain Lion, OS X 10.9 Mavericks

Setup port forwarding

If your future server is behind a router, you’ll most likely need to setup port forwarding for the following ports:

  • UDP 500 for ISAKMP/IKE
  • UDP 1701 for L2TP
  • UDP 4500 for IPsec NAT Traversal
  • Optional: TCP 1723 for PPTP

Apple has more information on common ports used.

OS X 10.9 Mavericks fix

This step is only required on OS X 10.9 Mavericks

In OS X Mavericks, there was a change to the /usr/sbin/racoon program which breaks L2TP access from remote clients when traversing NAT. This is a known bug and I have filed a bug report with Apple. This also breaks Apple’s own Server App since it simply automates what we’re doing manually here. There are two known solutions.

Solution 1: Use a modified variation of the official fix . This modified installer does not check for the existence of the Apple Download the modified package MavericksVPNUpdateServerAppLess.pkg.

Also checkout the official Apple KB article on this problem and their fix for users who have the installed on their systems.

Solution 2: Replace /usr/sbin/racoon with a version from Mountain Lion. If you don’t have your own backup available, you can download my backup of racoon from Mountain Lion. Simply unzip, move the executable into /usr/sbin, and reboot your Mac [or kill and restart racoon].

For example:

Add a shared secret to your keychain

Run the following command in Terminal after replacing SHARED-SECRET-PHRASE with your own secret phrase. When you login to your VPN server from a client, both an account password and secret phrase will be needed.

Configure Apple’s vpnd Service

Download Example configuration files (and racoon binary from Mountain Lion)

Modify the configuration file below and save it to the following location. Set ownership to root:wheel and chmod 644.

You need to modify the following lines with your own information:

  • Lines 19-20 under “OfferedServerAddresses”

    These two lines should be changed to the DNS domains you want your VPN clients to use. In this example, I’m providing my local router ( and a Google DNS domain as a secondary (

  • Lines 29-30 under “DestAddressRanges”

    These two lines specify the start and end IP address range that will be given to clients when they login. In this example, my clients are given an IP address between and Ideally, you should choose a range that is outside of the range that your router will assign so that you avoid IP address conflicts. For example, my router is configured with a DHCP range of to 10.0.249.

This configuration file also enables PPTP in addition to L2TP. If you wish to enable this as well, modify lines 84-85 and 94-95.

Create a Launchd profile

Take the plist configuration file below and save it to the following location. Set ownership to root:wheel and chmod 644.

Launchd Loading and Unloading

This command will load the launchd configuration and start the vpnd service. The VPN service will automatically start when you reboot your computer.

This command will unload the launchd configuration and stop the vpnd service. This will also stop VPN services from starting when you reboot.


If things just aren’t working, take a look in Console to see what errors vpnd is reporting.

95 thoughts on “How to Setup a L2TP VPN Server on OS X

    1. Just use the ones on the Mac. You can always create one VPN user with a username and password on your Mac, that way you do not have to create multiple accounts for people for the sole purpose of giving them access to VPN.

  1. Followed your instructions on El Cap (10.11). Worked perfectly first time. (I removed the PPTP stanza from the config plist, as I only wanted to offer the more secure L2TP [to myself :-)] )

    Thanks again!

  2. Here it is again with the delimiters replaced by descriptors. Replace the descriptors back with the delimiters before you type the lines in.

  3. Thanks for posting these instructions! I was able to configure everything and can establish a VPN connection to a server at home. However, I can only address the resources back home via ip, ip addresses cannot get resolved, and none of my resources show up in the ‘network’ panel… Wondering where the issue might lie?

    1. I’ve only attempted to access directly via IP. Are you sending all traffic over the VPN? Are the client and VPN side gateways on the same subnet? That might cause some confusion that might be causing the issue. Broadcasts should traverse layer 2 like that. Having said that, I haven’t tried to access by name or look for network advertisements since I know the destination IPs by memory.

  4.[1]: ([91440]) Service exited with abnormal code: 3 I only get this error when I follow this tutorial. I am running 10.10. What does this mean?

  5. The problem I am having is regarding the port forwarding… I have setup the L2TP ports in my Bell Home Hub 2000 (canadian isp), but the traffic is not getting through. Error on iOS device: the L2TP-VPN server did not respond.

    1. If the router is setup with all of the port forwarding, maybe Bell is blocking some on their end. Can the iOS device connect when it’s on the same network at home?

  6. I have the same problem like Matt ist only authenticates the SHARED-SECRET-PHRASE. Not the given username and password.

    Any idea ?

  7. Fantastic and dead simple to setup! Only one issue I need pointers on – I can connect my Android phone to the VPN when I point it at my server’s local IP (while on the same LAN) but it seems to timeout if I try to connect from the public internet IP. Any ideas?

    2014-11-20 23:39:53 EST Incoming call… Address given to client = Thu Nov 20 23:39:53 2014 : Directory Services Authorization plugin initialized Thu Nov 20 23:39:53 2014 : publish_entry SCDSet() failed: Success! Thu Nov 20 23:39:53 2014 : publish_entry SCDSet() failed: Success! Thu Nov 20 23:39:53 2014 : publish_entry SCDSet() failed: Success! Thu Nov 20 23:39:53 2014 : L2TP incoming call in progress from ‘Public IP‘… Thu Nov 20 23:39:53 2014 : L2TP received SCCRQ Thu Nov 20 23:39:53 2014 : L2TP sent SCCRP 2014-11-20 23:40:13 EST –> Client with address = has hungup

  8. Thanks – got this working with my MacBook Air as client and my MacMini as the VPS server…happy days.

    Trying to configure my Samsung Galaxy S4 as a client and it needs a pre-shared-key. Can’t see how to configure the VPN server to have such a key. Is this possible using Racoon on MacOS X?

    Thx, NICK

  9. Thanks for this!!! So I got L2TP to work but for some reason can’t get PPTP. I’d like to use PPTP since the port fwd for it won’t conflict with Back to My Mac. I used the above.

    1. The only way I managed to get pptp working was to disable encryption which to me seemed like a very bad idea. Look for CCPEnable in the plist file and set it to zero. Also make sure you add PAP authentication (see my other comment) otherwise anyone would be able to login with any random username and password.

  10. Hey sorry to be a noodge but I have 10.9.5 which I assume means I don’t need any replacement config files. So what are the steps to get this going? I have been away from the command line for a bit and want to get going again.

    1. MacDevGuy, you won’t need to replace replace racoon because Apple finally fixed the problem in 10.9.2, but you will still need to edit and add the plist configuration files to enable the service.

  11. Just trying to implement this on 10.9.3 but I don’t have a file at this location:


    Any thoughts?

  12. Offer– I have a copy of 10.6.8 server. I could configure the VPN through Apple’s Server Admin utility GUI, then send you a copy of the config files. Would that be helpful?

    How would you like it configured. And what files should I post here?

    1. Thanks for the offer – that’s great. I’m not sure what the configuration options are in Server but I just want to have the L2TP server only configured. Internal IP address range would be – (2 addresses).

      DNS would be

      For the config file, not sure if there are more than what’s referenced above in the original post. At least this one:


      I appreciate the help.

  13. I set everything up and it worked. The issue I have (Snow Leopard – I know – untested) is that I can log in with any account and password, even an account that doesn’t exist on the Mac. Any ideas?

    1. Huh, that’s a new one. I assume l2tp, and it doesn’t ask for a shared secret? You might try man vpnd to see if there are any differences in the configuration parameters between 10.6 and 10.8+ around the authentication mechanism. Some digging would be needed. Why not upgrade?

      1. Yes – l2tp. The shared secret does work. When I take that out of the connecting client I get denied access. But as long as the shared secret is in the connecting client, the server lets me in regardless of what I put as the username and password.

        I ran a man vpnd on both my Snow Leopard box and my Mavericks box. Exact same output (except Mavericks adds “vpnd(5)” to the SEE ALSO section). Both are dated 21 August 2003.

        The reason I’m not upgrading is just because the Snow Leopard machine is an old Mac mini. Would love to figure out how to make it work.

    2. I have the same issue with Lion (10.7.3) only the shared secret is checked before succesful login :-/ Also thank you so much for a great article… spent last night down the winding openVPN-road without satisfacotry results… this really was only 15 minutes thanks! 🙂

    3. I’m actually getting this same issue. I can log in with any account/pass (even a blank pass) once the shared secret is correct. Anyone figure out why this is happening?

      1. I ran into the same issue and was able to resolve it by adding a few lines to the configuration file after reading the VPN2 manual. Add the following lines after line 54 (for L2TP) and after the corresponding line in the PPTP section (if you want that section). AuthenticatorPlugins DSAuth AuthenticatorProtocol PAP

        1. Sorry, the html ate all the keys and brackets:

          AuthenticatorPlugins DSAuth AuthenticatorProtocol PAP

  14. For an all Apple L2TP VPN configuration, might you know what the “Shared Secret” requirements are for:

    Length (minimum and maximum permitted)

    Character Set (which characters are permitted and which are not?)

    Thanks in advance for any help, I’ve been searching all over for this, and there seem to be no answers to be found.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.