| 1 |
# Configuration for {{vpnservice.id}} |
| 2 |
config setup |
| 3 |
{% if nat_traversal is defined and nat_traversal is not none -%} |
| 4 |
nat_traversal={{nat_traversal}} |
| 5 |
{% endif -%} |
| 6 |
virtual_private={{virtual_privates}} |
| 7 |
conn %default |
| 8 |
keylife=60m |
| 9 |
keyingtries=%forever |
| 10 |
{% for ipsec_site_connection in vpnservice.ipsec_site_connections if ipsec_site_connection.admin_state_up |
| 11 |
-%} |
| 12 |
conn {{ipsec_site_connection.id}} |
| 13 |
{% if ipsec_site_connection['local_ip_vers'] == 6 -%} |
| 14 |
# To recognize the given IP addresses in this config |
| 15 |
# as IPv6 addresses by pluto whack. Default is ipv4 |
| 16 |
connaddrfamily=ipv6 |
| 17 |
# openswan can't process defaultroute for ipv6. |
| 18 |
# Assign gateway address as leftnexthop |
| 19 |
leftnexthop={{ipsec_site_connection.external_ip}} |
| 20 |
# rightnexthop is not mandatory for ipsec, so no need in ipv6. |
| 21 |
{% else -%} |
| 22 |
# NOTE: a default route is required for %defaultroute to work... |
| 23 |
leftnexthop=%defaultroute |
| 24 |
rightnexthop=%defaultroute |
| 25 |
{% endif -%} |
| 26 |
left={{ipsec_site_connection.external_ip}} |
| 27 |
leftid={{ipsec_site_connection.local_id}} |
| 28 |
auto={{ipsec_site_connection.initiator}} |
| 29 |
# NOTE:REQUIRED |
| 30 |
# [subnet] |
| 31 |
{% if ipsec_site_connection['local_cidrs']|length == 1 -%} |
| 32 |
leftsubnet={{ipsec_site_connection['local_cidrs'][0]}} |
| 33 |
{% else -%} |
| 34 |
leftsubnets={ {{ipsec_site_connection['local_cidrs']|join(' ')}} } |
| 35 |
{% endif -%} |
| 36 |
# [updown] |
| 37 |
# What "updown" script to run to adjust routing and/or firewalling when |
| 38 |
# the status of the connection changes (default "ipsec _updown"). |
| 39 |
# "--route yes" allows to specify such routing options as mtu and metric. |
| 40 |
leftupdown="ipsec _updown --route yes" |
| 41 |
###################### |
| 42 |
# ipsec_site_connections |
| 43 |
###################### |
| 44 |
# [peer_address] |
| 45 |
right={{ipsec_site_connection.peer_address}} |
| 46 |
# [peer_id] |
| 47 |
rightid={{ipsec_site_connection.peer_id}} |
| 48 |
# [peer_cidrs] |
| 49 |
rightsubnets={ {{ipsec_site_connection['peer_cidrs']|join(' ')}} } |
| 50 |
# rightsubnet=networkA/netmaskA, networkB/netmaskB (IKEv2 only) |
| 51 |
# [mtu] |
| 52 |
mtu={{ipsec_site_connection.mtu}} |
| 53 |
# [dpd_action] |
| 54 |
dpdaction={{ipsec_site_connection.dpd_action}} |
| 55 |
# [dpd_interval] |
| 56 |
dpddelay={{ipsec_site_connection.dpd_interval}} |
| 57 |
# [dpd_timeout] |
| 58 |
dpdtimeout={{ipsec_site_connection.dpd_timeout}} |
| 59 |
# [auth_mode] |
| 60 |
authby=secret |
| 61 |
###################### |
| 62 |
# IKEPolicy params |
| 63 |
###################### |
| 64 |
#ike version |
| 65 |
ikev2={{ipsec_site_connection.ikepolicy.ike_version}} |
| 66 |
# [encryption_algorithm]-[auth_algorithm];[pfs] |
| 67 |
ike={{ipsec_site_connection.ikepolicy.encryption_algorithm}}-{{ipsec_site_connection.ikepolicy.auth_algorithm}};{{ipsec_site_connection.ikepolicy.pfs}} |
| 68 |
{% if ipsec_site_connection.ikepolicy.phase1_negotiation_mode == "aggressive" -%} |
| 69 |
aggressive=yes |
| 70 |
{% endif -%} |
| 71 |
# [lifetime_value] |
| 72 |
ikelifetime={{ipsec_site_connection.ikepolicy.lifetime_value}}s |
| 73 |
# NOTE: it looks lifetime_units=kilobytes can't be enforced (could be seconds, hours, days...) |
| 74 |
########################## |
| 75 |
# IPsecPolicys params |
| 76 |
########################## |
| 77 |
# [transform_protocol] |
| 78 |
phase2={{ipsec_site_connection.ipsecpolicy.transform_protocol}} |
| 79 |
{% if ipsec_site_connection.ipsecpolicy.transform_protocol == "ah" -%} |
| 80 |
# AH protocol does not support encryption |
| 81 |
# [auth_algorithm];[pfs] |
| 82 |
phase2alg={{ipsec_site_connection.ipsecpolicy.auth_algorithm}};{{ipsec_site_connection.ipsecpolicy.pfs}} |
| 83 |
{% elif 'cm' in ipsec_site_connection.ipsecpolicy.encryption_algorithm -%} |
| 84 |
# [encryption_algorithm];[pfs] |
| 85 |
phase2alg={{ipsec_site_connection.ipsecpolicy.encryption_algorithm}};{{ipsec_site_connection.ipsecpolicy.pfs}} |
| 86 |
{% else -%} |
| 87 |
# [encryption_algorithm]-[auth_algorithm];[pfs] |
| 88 |
phase2alg={{ipsec_site_connection.ipsecpolicy.encryption_algorithm}}-{{ipsec_site_connection.ipsecpolicy.auth_algorithm}};{{ipsec_site_connection.ipsecpolicy.pfs}} |
| 89 |
{% endif -%} |
| 90 |
# [encapsulation_mode] |
| 91 |
type={{ipsec_site_connection.ipsecpolicy.encapsulation_mode}} |
| 92 |
# [lifetime_value] |
| 93 |
lifetime={{ipsec_site_connection.ipsecpolicy.lifetime_value}}s |
| 94 |
# lifebytes=100000 if lifetime_units=kilobytes (IKEv2 only) |
| 95 |
{% endfor -%} |