Chef receipe to setup L2TP over IPSec VPN, or IPSec tunneling site-to-site VPN using openswan.
Switch branches/tags
Nothing to show
Clone or download


Collection of recipes that configure and install Ubuntu-based networking VPN gateway, with support for for both peer-to-peer and site-to-site VPN. It includes installation and configuration of ipsec and xl2tpd, as well as iptables services for NAT routing.

L2TP over IpSec VPN

This recipe installs and configures openswan services for per-user l2tp over ipsec vpn access.

Tunneling Cisco ASA Compatible site-to-site VPN

This recipe installs site-to-site VPN that's been verified to work with Cisco ASA 5000 series appliances.

Warning: the two recipes are currently incompatible (as they override /etc/ipsec.conf file). Meaning that you can either setup a tunnelling site-to-site VPN gateway, or user-based peer-to-peer L2TP VPN gateway, but not both on the same machine. This is likely to be fixed in future versions.


Currently tested only on Ubuntu 12.

Peer to Peer

Expects a 'users' databag, with user records formatted like this:

    "groups":["sysadmin", "vpn"],
    "comment":"Jane Doe",

In order to remove user record without deleting the data bag, add a key to the databag as follows:

    "groups":["sysadmin", "vpn"],
    "comment":"Jane Doe",
    "action": "remove"

This follows a precedent set in the users cookbook maintained by Opscode.

Site to Site

Example configuration (where 'office' is just a name for the connection):

# Define locally routable subnets
node.override['openswan']['tunnel']['connections']['office']['local']['subnets'] = %w(
  # etc...

# External to OpenSwan site's local subnet
node.override['openswan']['tunnel']['connections']['office']['remote']['subnets'] = %w( 

# VPN firewall external IP to connect to
node.override['openswan']['tunnel']['connections']['office']['remote']['ipaddress'] = 'W.X.Y.Z'

# Run the recipe
include_recipe 'openswan::tunnel'


Default attributes should be overwritten to match your role or environment needs.

default['openswan']['ppp_link_network'] = ""
default['openswan']['preshared_key'] = "letmein"
default['openswan']['private_virtual_interface_ip'] = ""
default['openswan']['private_ip_range'] = ""
default['openswan']['xl2tpd_path'] = "/etc/xl2tpd"
default['openswan']['ppp_path'] = "/etc/ppp"