summaryrefslogtreecommitdiff
path: root/data/templates/ipsec/swanctl.conf.tmpl
blob: 06fd8e8c226d2fd43da3e023da2d0d420d4c38ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
### Autogenerated by vpn_ipsec.py ###
{% import 'ipsec/swanctl/profile.tmpl' as profile_tmpl %}
{% import 'ipsec/swanctl/peer.tmpl' as peer_tmpl %}

connections {
{% if profile is defined %}
{%   for name, profile_conf in profile.items() if profile_conf.disable is not defined and profile_conf.bind is defined and profile_conf.bind.tunnel is defined %}
{{     profile_tmpl.conn(name, profile_conf, ike_group, esp_group) }}
{%   endfor %}
{% endif %}
{% if site_to_site is defined and site_to_site.peer is defined %}
{%   for peer, peer_conf in site_to_site.peer.items() if peer not in dhcp_no_address and peer_conf.disable is not defined %}
{{     peer_tmpl.conn(peer, peer_conf, ike_group, esp_group) }}
{%   endfor %}
{%  endif %}
{% if remote_access is defined and remote_access is not none %}
{%   set ike = ike_group[peer_conf.ike_group] %}
    road_warrior {
        proposals = {{ ike | get_esp_ike_cipher | join(',') }}
        version = {{ ike.key_exchange[4:] if ike is defined and ike.key_exchange is defined else "0" }}
        local_addrs  = 192.168.0.1
        local {
            auth = eap-peap
            certs = moonCert.pem
        }
        remote {
            auth = eap-peap
        }
        send_certreq = no
        children {
            net {
                local_ts = 10.1.0.0/16
                esp_proposals = {{ esp_group[peer_conf.default_esp_group] | get_esp_ike_cipher | join(',') }}
            }
        }
    }
{%  endif %}
}

secrets {
{%  if profile is defined %}
{%    for name, profile_conf in profile.items() if profile_conf.disable is not defined and profile_conf.bind is defined and profile_conf.bind.tunnel is defined %}
{%      if profile_conf.authentication.mode == 'pre-shared-secret' %}
{%        for interface in profile_conf.bind.tunnel %}
    ike-dmvpn-{{ interface }} {
        secret = {{ profile_conf.authentication.pre_shared_secret }}
    }
{%        endfor %}
{%      endif %}
{%    endfor %}
{%  endif %}
{%  if site_to_site is defined and site_to_site.peer is defined %}
{%    set ns = namespace(local_key_set=False) %}
{%    for peer, peer_conf in site_to_site.peer.items() if peer not in dhcp_no_address and peer_conf.disable is not defined %}
{%      set peer_name = peer.replace(".", "-").replace("@", "") %}
{%      if peer_conf.authentication.mode == 'pre-shared-secret' %}
    ike_{{ peer_name }} {
{%        if peer_conf.local_address is defined %}
        id-local = {{ peer_conf.local_address }} # dhcp:{{ peer_conf.dhcp_interface if 'dhcp_interface' in peer_conf else 'no' }}
{%        endif %}
        id-remote = {{ peer }}
{%        if peer_conf.authentication.id is defined %}
        id-localid = {{ peer_conf.authentication.id }}
{%        endif %}
{%        if peer_conf.authentication.remote_id is defined %}
        id-remoteid = {{ peer_conf.authentication.remote_id }}
{%        endif %}
        secret = "{{ peer_conf.authentication.pre_shared_secret }}"
    }
{%      elif peer_conf.authentication.mode == 'x509' %}
    private_{{ peer_name }} {
        file = {{ peer_conf.authentication.x509.certificate }}.pem
{%        if peer_conf.authentication.x509.passphrase is defined %}
        secret = "{{ peer_conf.authentication.x509.passphrase }}"
{%        endif %}
    }
{%      elif peer_conf.authentication.mode == 'rsa' and not ns.local_key_set %}
{%        set ns.local_key_set = True %}
    rsa_local {
        file = {{ rsa_local_key }}
    }
{%      endif %}
{%    endfor %}
{%  endif %}
}