strongswan IPSEC

https://wiki.strongswan.org/projects/strongswan/wiki/ConfigurationFiles

ipsec.conf: conn <name>

General Connection Parameters

aaa_identity = <id>

defines the identity of the AAA backend used during IKEv2 EAP authentication. This is required if
the EAP client uses a method that verifies the server identity (such as EAP-TLS), but it does not
match the IKEv2 gateway identity.

ah = <cipher suites>

comma-separated list of AH algorithms to be used for the connection, e.g. sha1-sha256-modp1024.
The notation is integrity[-dhgroup]. For IKEv2, multiple algorithms (separated by -) of the same type
can be included in a single proposal. IKEv1 only includes the first algorithm in a proposal.
Only either the ah or the esp keyword may be used, AH+ESP bundles are not supported.

There is no default AH cipher suite since by default ESP is used. The daemon adds its extensive default
proposal to the configured value. To restrict it to the configured proposal an exclamation mark (!) can
be added at the end.
Note: As a responder, the daemon defaults to selecting the first configured proposal that’s also
supported by the peer. By disabling charon.prefer_configured_proposals in strongswan.conf this may
be changed to selecting the first acceptable proposal sent by the peer instead.
In order to restrict a responder to only accept specific cipher suites, the strict flag (!, exclamation mark)
can be used, e.g: sha256-sha512-modp2048!

If dh-group is specified, CHILD_SA/Quick Mode setup and rekeying include a separate Diffe-Hellman
exchange (refer to esp for details).

Refer to IKEv1CipherSuites and IKEv2CipherSuites for a list of valid keywords.

Available since 5.1.1.

aggressive = yes | no

whether to use IKEv1 Aggressive or Main Mode (the default). Available since 5.0.0.

also = <name>

includes conn section <name>. Some aspects of this changed with 5.2.0 (refer to IpsecConf for details).

authby = pubkey | rsasig | ecdsasig | psk | secret | xauthrsasig | xauthpsk | never

how the two security gateways should authenticate each other; acceptable values are secret or psk
for pre-shared secrets, pubkey (the default) for public key signatures as well as the synonyms rsasig
for RSA digital signatures and ecdsasig for Elliptic Curve DSA signatures.
never can be used if negotiation is never to be attempted or accepted (useful for shunt-only conns).
Digital signatures are superior in every way to shared secrets. IKEv1 additionally supports the values
xauthpsk and xauthrsasig that will enable eXtended Authentication (XAuth) in addition to IKEv1 main
mode based on shared secrets or digital RSA signatures, respectively.
This parameter is deprecated for IKEv2 connections (and IKEv1 connections since 5.0.0), as two peers
do not need to agree on an authentication method. Use the left|rightauth parameter instead to define
authentication methods.

auto = ignore | add | route | start

what operation, if any, should be done automatically at IPsec startup. add loads a connection without
starting it. route loads a connection and installs kernel traps. If traffic is detected between
leftsubnet and rightsubnet, a connection is established. start loads a connection and brings
it up immediately. ignore ignores the connection. This is equal to deleting a connection from the config
file. Relevant only locally, other end need not agree on it.

closeaction = none | clear | hold | restart

defines the action to take if the remote peer unexpectedly closes a CHILD_SA (see dpdaction for
meaning of values). A closeaction should not be used if the peer uses reauthentication or uniqueids checking,
as these events might trigger the defined action when not desired. Prior to 5.1.0, closeaction was
not supported for IKEv1 connections.

compress = yes | no

whether IPComp compression of content is proposed on the connection (link-level compression does not work on
encrypted data, so to be effective, compression must be done before encryption). A value of yes causes the daemon
to propose both compressed and uncompressed, and prefer compressed. A value of no prevents the daemon from proposing or accepting compression.

dpdaction = none | clear | hold | restart

controls the use of the Dead Peer Detection protocol (DPD, RFC 3706) where R_U_THERE notification messages
(IKEv1) or empty INFORMATIONAL messages (IKEv2) are periodically sent in order to check the liveliness of the
IPsec peer. The values clear, hold, and restart all activate DPD and determine the action to perform on a timeout.
With clear the connection is closed with no further actions taken. hold installs a trap policy, which will catch
matching traffic and tries to re-negotiate the connection on demand. restart will immediately trigger an attempt
to re-negotiate the connection. The default is none which disables the active sending of DPD messages.

dpddelay = 30s | <time>

defines the period time interval with which R_U_THERE messages/INFORMATIONAL exchanges are sent to the peer.
These are only sent if no other traffic is received. In IKEv2, a value of 0 sends no additional INFORMATIONAL
messages and uses only standard messages (such as those to rekey) to detect dead peers.

dpdtimeout = 150s | <time>

defines the timeout interval, after which all connections to a peer are deleted in case of inactivity.
This only applies to IKEv1, in IKEv2 the default retransmission timeout applies, as every exchange is used to
detect dead peers.

inactivity = <time>

defines the timeout interval, after which a CHILD_SA is closed if it did not send or receive any traffic.
Not supported for IKEv1 connections prior to 5.0.0.

eap_identity = <id>

defines the identity the client uses to reply to an EAP Identity request. If defined on the EAP server, the defined
identity will be used as peer identity during EAP authentication. The special value %identity uses the EAP Identity method
to ask the client for a EAP identity. If not defined, the IKEv2 identity will be used as EAP identity.

esp = <cipher suites>

comma-separated list of ESP encryption/authentication algorithms to be used for the connection, e.g.
aes128-sha256. The notation is encryption-integrity[-dhgroup][-esnmode].
For IKEv2, multiple algorithms (separated by -) of the same type can be included in a single proposal.
IKEv1 only includes the first algorithm in a proposal. Only either the ah or the esp keyword may
be used, AH+ESP bundles are not supported.

Defaults to aes128-sha256 (aes128-sha1,3des-sha1 before 5.4.0). The daemon adds its extensive default
proposal to this default or the configured value. To restrict it to the configured proposal an exclamation mark (!)
can be added at the end.
Note: As a responder, the daemon defaults to selecting the first configured proposal that’s also
supported by the peer. By disabling charon.prefer_configured_proposals in strongswan.conf this may
be changed to selecting the first acceptable proposal sent by the peer instead.
In order to restrict a responder to only accept specific cipher suites, the strict flag (!, exclamation mark)
can be used, e.g: aes256-sha512-modp4096!

If dh-group is specified, CHILD_SA rekeying and initial negotiation include a separate Diffe-Hellman
exchange (since 5.0.0 this also applies to IKEv1 Quick Mode). However, for IKEv2, the keys of the CHILD_SA
created implicitly with the IKE_SA will always be derived from the IKE_SA’s key material. So any DH group
specified here will only apply when the CHILD_SA is later rekeyed or is created with a separate CREATE_CHILD_SA
exchange. Therefore, a proposal mismatch might not immediately be noticed when the SA is established,
but may later cause rekeying to fail.

Valid values for esnmode are esn and noesn. Specifying both negotiates extended sequence
number support with the peer, the default is noesn.

Refer to IKEv1CipherSuites and IKEv2CipherSuites for a list of valid keywords.

forceencaps = yes | no

force UDP encapsulation for ESP packets even if no NAT situation is detected.
This may help to surmount restrictive firewalls. In order to force the peer to
encapsulate packets, NAT detection payloads are faked.
Not supported for IKEv1 connections prior to 5.0.0.

fragmentation = yes | accept | force | no

whether to use IKE fragmentation (proprietary IKEv1 extension or IKEv2 fragmentation as per RFC 7383).
Fragmented messages sent by a peer are always processed irrespective of the value of this option (even when set to no).
If set to yes (the default since 5.5.1) and the peer supports it, oversized IKE messages will be sent in fragments (the
maximum fragment size can be configured in strongswan.conf). If set to accept (available since 5.5.3) support for
fragmentation is announced to the peer but the daemon does not send its own messages in fragments.
If set to force (only supported for IKEv1) the initial IKE message will already be fragmented if required.
Available for IKEv1 connections since 5.0.2 and for IKEv2 connections since 5.2.1.

ike = <cipher suites>

comma-separated list of IKE/ISAKMP SA encryption/authentication algorithms to be used, e.g.
aes128-sha256-modp3072. The notation is encryption-integrity[-prf]-dhgroup. In IKEv2, multiple algorithms
and proposals may be included, such as aes128-aes256-sha1-modp3072-modp2048,3des-sha1-md5-modp1024.

The ability to configure a PRF algorithm different to that defined for integrity protection was added with 5.0.2.
If no PRF is configured, the algorithms defined for integrity are proposed as PRF. The prf keywords are the same as
the integrity algorithms, but have a prf prefix (such as prfsha1, prfsha256 or prfaesxcbc).

Defaults to aes128-sha256-modp3072 (aes128-sha1-modp2048,3des-sha1-modp1536 before 5.4.0) for IKEv1.
The daemon adds its extensive default proposal to this default or the configured value. To restrict it to the
configured proposal an exclamation mark (!) can be added at the end.
Refer to IKEv1CipherSuites and IKEv2CipherSuites for a list of valid keywords.

Note: As a responder both daemons accept the first supported proposal received from the peer. In order
to restrict a responder to only accept specific cipher suites, the strict flag (!, exclamation mark)
can be used, e.g: aes256-sha512-modp4096!

ikedscp = 000000 | <DSCP field>

Differentiated Services Field Codepoint to set on outgoing IKE packets sent
from this connection. The value is a six digit binary encoded string defining
the Codepoint to set, as defined in RFC 2474.

ikelifetime = 3h | <time>

how long the keying channel of a connection (ISAKMP or IKE SA) should last before being renegotiated.
Also see Expiry and Rekey.

installpolicy = yes | no

decides whether IPsec policies are installed in the kernel by the charon daemon for a given connection.
Allows peaceful cooperation e.g. with the Mobile IPv6 mip6d daemon who wants to control the kernel policies.

keyexchange = ike | ikev1 | ikev2

method of key exchange; which protocol should be used to initialize the connection.
Prior to 5.0.0 connections marked with ikev1 were initiated with Pluto, those marked with ikev2 with Charon.
An incoming request from the remote peer was handled by the correct daemon, unaffected from the keyexchange setting.
Starting with strongSwan 4.5.0 the default value ike is a synonym for ikev2, whereas in older strongSwan releases ikev1 was assumed.
Since 5.0.0 both protocols are handled by Charon and connections marked with ike will use IKEv2 when initiating, but accept any protocol version when responding.

keyingtries = 3 | <number> | %forever

how many attempts (a positive integer or %forever) should be made to negotiate a connection, or a replacement
for one, before giving up (default 3). The value %forever means ‘never give up’. Relevant only locally, other end need
not agree on it.

lifebytes = <number>

the number of bytes transmitted over an IPsec SA before it expires. Not supported for IKEv1 connections prior to 5.0.0.

lifepackets = <number>

the number of packets transmitted over an IPsec SA before it expires. Not supported for IKEv1 connections prior to 5.0.0.

lifetime = 1h | <time>

how long a particular instance of a connection (a set of encryption/authentication keys for user packets)
should last, from successful negotiation to expiry; acceptable values are an integer optionally followed by
s (a time in seconds) or a decimal number followed by m, h, or d (a time in minutes, hours,
or days respectively) (default 1h, maximum 24h). Normally, the connection is renegotiated (via the
keying channel) before it expires (see margintime). The two ends need not exactly agree on lifetime, although if they
do not, there will be some clutter of superseded connections on the end which thinks the lifetime is longer.
Also see Expiry and Rekey.

marginbytes = <number>

how many bytes before IPsec SA expiry (see lifebytes) should attempts to negotiate a replacement begin.

marginpackets = <number>

how many packets before IPsec SA expiry (see lifepackets) should attempts to negotiate a replacement begin.

margintime = 9m | <time>

how long before connection expiry or keying-channel expiry should attempts to negotiate a replacement begin; acceptable values
as for lifetime (default 9m). Relevant only locally, other end need not agree on it. Also see Expiry and Rekey.

mark = <value>[/<mask>]

sets an XFRM mark on the inbound policy (before 5.5.2 also on the IPsec SA) and outbound IPsec SA and policy.
If the mask is missing then a default mask of 0xffffffff is assumed. Since 5.3.0 the special value %unique
assigns a unique value to each newly created IPsec SA (used e.g. in combination with the forecast or
connmark plugins). To additionally make the mark unique for each IPsec SA direction (in/out) the special value
%unique-dir may be used since 5.6.0.

mark_in = <value>[/<mask>]

sets an XFRM mark on the inbound policy (and before 5.5.2 also on the inbound SA). If the mask is missing then
a default mask of 0xffffffff is assumed.

mark_out = <value>[/<mask>]

sets an XFRM mark on the outbound IPsec SA and policy. If the mask is missing then
a default mask of 0xffffffff is assumed.

mobike = yes | no

enables the IKEv2 MOBIKE protocol defined by RFC 4555. If set to no, the charon
daemon will not actively propose MOBIKE as initiator and ignore the MOBIKE_SUPPORTED
notify as responder.

modeconfig = push | pull

defines which mode is used to assign a virtual IP. Currently relevant for IKEv1 only since IKEv2 always uses
the configuration payload in pull mode. Cisco VPN gateways usually operate in push mode.
In versions prior to 5.1.1 the charon daemon did not support push mode.
This setting must be the same on both sides.

reauth = yes | no

whether rekeying of an IKE_SA should also reauthenticate the peer. In IKEv1, reauthentication is always done.
In IKEv2, a value of no rekeys without uninstalling the IPsec SAs, a value of yes (the default)
creates a new IKE_SA from scratch and tries to recreate all IPsec SAs.

rekey = yes | no

whether a connection should be renegotiated when it is about to expire. The two ends need not agree, but
while a value of no prevents the daemon from requesting renegotiation, it does not prevent responding
to renegotiation requested from the other end, so no will be largely ineffective unless both ends agree on it.
Also see reauth.

rekeyfuzz = 100% | <percentage>

maximum percentage by which marginbytes, marginpackets and margintime should be randomly increased to randomize
rekeying intervals (important for hosts with many connections); acceptable values are an integer, which may exceed 100,
followed by a ‘%’ .
The value of marginTYPE, after this random increase, must not exceed lifeTYPE (where TYPE is one of bytes, packets or time).
The value 0% will suppress randomization. Relevant only locally, other end need not agree on it.
Also see Expiry and Rekey.

replay_window = -1 | <number>

The IPsec replay window size for this connection. With the default of -1 the value configured with charon.replay_window in
strongswan.conf is used. Larger values than 32 are supported using the Netlink backend only, a value of 0 disables IPsec
replay protection. Available since 5.2.0.

reqid = <number>

sets the reqid for a given connection to a pre-configured fixed value.

sha256_96 = no | yes

HMAC-SHA-256 is used with 128-bit truncation with IPsec. For compatibility with implementations that incorrectly use 96-bit
truncation this option may be enabled to configure the shorter truncation length in the kernel. This is not negotiated, so this
only works with peers that use the incorrect truncation length (or have this option enabled). Available since 5.5.3.

tfc = <value>

number of bytes to pad ESP payload data to. Traffic Flow Confidentiality is currently supported in IKEv2 and applies to outgoing packets only. The special value %mtu fills up ESP packets with padding to have the size of the MTU.

type = tunnel | transport | transport_proxy | passthrough | drop

the type of the connection; currently the accepted values are tunnel, signifying a host-to-host,
host-to-subnet, or subnet-to-subnet tunnel; transport, signifying host-to-host transport mode;
transport_proxy, signifying the special Mobile IPv6 transport proxy mode;
passthrough, signifying that no IPsec processing should be done at all; drop, signifying that packets
should be discarded.

xauth = client | server

specifies the role in the XAuth protocol if activated by authby=xauthpsk or authby=xauthrsasig.

xauth_identity = <id>

defines the identity/username the client uses to reply to an XAuth request. If not defined, the IKEv1 identity will be used as XAuth identity.

left|right End Parameters

Connection descriptions are defined in terms of a left endpoint and a right endpoint. For example, the
two parameters leftid and rightid specify the identity of the left and the right endpoint. For every
connection description an attempt is made to figure out whether the local endpoint should act as the left or
the right endpoint. This is done by matching the IP addresses defined for both endpoints with the
IP addresses assigned to local network interfaces. If a match is found then the role (left or right) that
matches is going to be considered “local”. If no match is found during startup, “left” is considered “local”.

left|right = <ip address> | <fqdn> | %any | %any4 | %any6 | range | subnet

The IP address of the participant’s public-network interface or one of several magic values.
The value %any for the local endpoint signifies an address to be filled in
(by automatic keying) during negotiation. If the local peer initiates the connection setup the routing table
will be queried to determine the correct local IP address. In case the local peer is responding to a connection
setup then any IP address that is assigned to a local interface will be accepted. The value %any4 restricts
address selection to IPv4 addresses, the value %any6 reistricts address selection to IPv6 addresses.

Prior to 5.0.0 specifying %any for the local endpoint was not supported for IKEv1 connections, instead
the keyword %defaultroute could be used, causing the value to be filled in automatically with the local
address of the default-route interface (as determined at IPsec startup time and during configuration
update). Either left or right may be %defaultroute, but not both.

The prefix % in front of a fully-qualified domain name or an IP address will implicitly set left|rightallowany=yes.

If %any is used for the remote endpoint it literally means any IP address.

If an FQDN is assigned it is resolved every time a configuration lookup is done. If DNS resolution times out,
the lookup is delayed for that time.

Since 5.1.1 connections can be limited to a specific range of hosts. To do so a range (10.1.0.0-10.2.255.255)
or a subnet (10.1.0.0/16) can be specified, and multiple addresses, ranges and subnets can be separated by commas.
While one can freely combine these items, to initiate the connection at least one non-range/subnet is required.

Please note that with the usage of wildcards multiple connection descriptions might match a given incoming
connection attempt. The most specific description is used in that case.

left|rightallowany = yes | no

a modifier for left|right, making it behave as %any although a concrete IP address has been
assigned. Recommended for dynamic IP addresses that can be resolved by DynDNS at IPsec startup or update time.

left|rightauth = <auth method>

Authentication method to use locally (left) or require from the remote (right) side. Acceptable values are pubkey
for public key encryption (RSA/ECDSA), psk for pre-shared key authentication, eap to [require the] use of the Extensible Authentication Protocol, and xauth for IKEv1 eXtended Authentication.

To require a trustchain public key strength for the remote side, specify the key type followed
by the minimum strength in bits (for example ecdsa-384 or rsa-2048-ecdsa-256).
To limit the acceptable set of hashing algorithms for trustchain validation, append hash algorithms
to pubkey or a key strength definition (for example pubkey-sha256-sha512, rsa-2048-sha256-sha384-sha512,
or rsa-2048-sha256-ecdsa-256-sha256-sha384).
Since 5.3.0 and unless disabled in strongswan.conf, or explicit IKEv2 signature constraints are
configured (see below), such key types and hash algorithms are also applied as constraints against IKEv2 signature
authentication schemes used by the remote side.

Since 5.3.0 and if both peers support RFC 7427 (“Signature Authentication in IKEv2”) specific hash
algorithms to be used during IKEv2 authentication may be configured. The syntax is the same as above,
but with ike: prefix (before 5.4.0 without that prefix).
For example, with ike:pubkey-sha384-sha256 a public key signature scheme with either SHA-384 or SHA-256
would get used for authentication, in that order and depending on the hash algorithms supported by the peer.
If no specific hash algorithms are configured, the default is to prefer an algorithm that matches or exceeds
the strength of the signature key.
If no constraints with ike: prefix are configured any signature scheme constraint (without ike: prefix) will
also apply to IKEv2 authentication, unless this is disabled in strongswan.conf (this is also the behavior before
5.4.0, which introduced the ike: prefix).
Since 5.6.1 RSASSA-PSS signatures are supported. To use or require them configure rsa/pss instead of rsa
as in e.g. ike:rsa/pss-sha256. If pubkey or rsa constraints are configured RSASSA-PSS signatures will only be
used/accepted if enabled in strongswan.conf.

In the case of eap, an optional EAP method can be appended. Currently defined methods are eap-aka,
eap-gtc, eap-md5, eap-mschapv2, eap-peap, eap-sim, eap-tls, eap-ttls, eap-dynamic, and eap-radius.
Alternatively, IANA assigned EAP method numbers are accepted. Vendor specific EAP methods are defined
in the form eap-type-vendor (e.g. eap-7-12345).
Since 5.3.0 signature and trust chain constraints for EAP-(T)TLS may be defined. To do so, append a
colon to the EAP method, followed by the key type/size and hash algorithm as discussed above.
For xauth, an XAuth authentication backend can be specified, such as xauth-generic or xauth-eap.
If XAuth is used in leftauth, Hybrid authentication is used. For traditional XAuth authentication, define XAuth in leftauth2.

Not supported for IKEv1 connections prior to 5.0.0.

left|rightauth2 = <auth method>

Same as left|rightauth, but defines an additional authentication exchange. In IKEv1, only XAuth can be used
in the second authentication round. IKEv2 supports multiple complete authentication rounds using
Multiple Authentication Exchanges defined in RFC 4739. This allows e.g. a separate authentication of host and user.

Not supported for IKEv1 connections prior to 5.0.0.

left|rightca = <issuer dn> | %same

the distinguished name of a certificate authority which is required to lie in the trust path going from the
left|right participant’s certificate up to the root certification authority.
%same means that the value configured for the other participant should be reused.

left|rightca2 = <issuer dn> | %same

Same as left|rightca but for the second authentication (IKev2 only).

left|rightcert = <path>

the path to the left|right participant’s X.509 certificate. The file can be coded either in PEM or DER format.
OpenPGP certificates are supported as well. Both absolute paths or paths relative to
/etc/ipsec.d/certs are accepted. By default left|rightcert sets left|rightid
to the distinguished name of the certificate’s subject. The left|right participant’s ID can be overridden
by specifying a left|rightid value which must be confirmed by the certificate, though.

Since 5.0.2 certificates can be configured in the form %smartcard[<slot nr>[@<module>]]:<keyid>, which
defines a specific certificate to load from a PKCS#11 backend for this connection (e.g. via the pkcs11 plugin).
See ipsec.secrets for details about smartcard definitions.
Defining a certificate on a smartcard with left|rightcert is only required if the automatic selection via left|rightid
is not sufficient, for example, if multiple certificates use the same subject.

Since 5.0.3 multiple certificate paths or PKCS#11 backends can be specified in a comma separated list.
The daemon chooses the certificate based on the received certificate requests, if possible, before enforcing
the first.

left|rightcert2 = <path>

Same as left|rightcert but for the second authentication round (IKEv2 only).

left|rightcertpolicy = <OIDs>

Comma separated list of certificate policy OIDs the peer’s certificate must have.
OIDs are specified using the numerical dotted representation. Not supported for IKEv1 connections prior to 5.0.0.

left|rightdns = <servers>

Comma separated list of DNS server addresses to exchange as configuration attributes. On the initiator,
a server is a fixed IPv4/IPv6 address, or %config4/%config6 to request attributes without an address.
On the responder, only fixed IPv4/IPv6 addresses are allowed and define DNS servers assigned to the client.
Available since 5.0.1.

left|rightfirewall = yes | no

whether the left|right participant is doing forwarding-firewalling (including masquerading)
using iptables for traffic from left|rightsubnet, which should be turned off for traffic to the
other subnet) once the connection is established. May not be used in the same connection description with
left|rightupdown. Implemented as a parameter to the default ipsec _updown script. Relevant only
locally, other end need not agree on it.

If one or both security gateways are doing forwarding firewalling (possibly including masquerading),
and this is specified using the firewall parameters, tunnels established with IPsec are exempted from
it so that packets can flow unchanged through the tunnels. (This means that all subnets connected in this
manner must have distinct, non-overlapping subnet address blocks.) This is done by the default
ipsec _updown script.

In situations calling for more control, it may be preferable for the user to supply his own updown script,
which makes the appropriate adjustments for his system.

left|rightgroups = <group list>

a comma-separated list of group names. If the left|rightgroups parameter is present then the peer must
be a member of at least one of the groups defined by the parameter. Groups may be used together with the
eap-radius plugin.

left|rightgroups2 = <group list>

Same as left|rightgroups but for the second authentication round defined with left|rightauth2.
Available since 5.0.1.

left|righthostaccess = yes | no

inserts a pair of INPUT and OUTPUT iptables rules using the default ipsec _updown script,
thus allowing access to the host itself in the case where the host’s internal interface is part
of the negotiated client subnet.

left|rightid = <id>

how the left|right participant should be identified for authentication; defaults to left|right or the subject of the
certificate configured with left|rightcert. If left|rightcert is configured the identity has to be confirmed by the
certificate, that is, it has to match the full subject DN or one of the subjectAltName extensions contained in the
certificate.

Can be an IP address, a fully-qualified domain name, an email address or a Distinguished Name for which the
ID type is determined automatically and the string is converted to the appropriate encoding. The rules for this
conversion are described on IdentityParsing. In versions before 5.0.0 fully-qualified domain names can be
preceded by an @ to avoid them being resolved to an IP address.

In certain special situations the identity parsing above might be inadequate or produce the wrong result.
Examples are the need to encode a FQDN as KEY_ID or the string parser being unable to produce the correct
binary ASN.1 encoding of a certificate’s DN. For these situations it is possible since 5.2.2 to enforce a specific
identity type and to provide the binary encoding of the identity. To do this a prefix may be used, followed by a
colon (:). If the number sign (#) follows the colon, the remaining data is interpreted as hex encoding, otherwise
the string is used as is as the identification data. Note: The latter implies that no conversion is performed for
non-string identities. For example, ipv4:10.0.0.1 does not create a valid ID_IPV4_ADDR IKE identity, as it does not
get converted to binary 0x0a000001. Instead, one could use ipv4:#0a000001 to get a valid identity, but just using
the implicit type with automatic conversion is usually simpler. The same applies to the ASN.1 encoded types.
The following prefixes are known: ipv4, ipv6, rfc822, email, userfqdn, fqdn, dns, asn1dn, asn1gn and keyid.
Custom type prefixes may be specified by surrounding the numerical type value with curly brackets.

Since 5.0.1 rightid for IKEv2 connections optionally takes a % as prefix in front of the identity.
If given it prevents the daemon from sending IDr in its IKE_AUTH request and will allow it to verify the
configured identity against the subject and subjectAltNames contained in the responder’s certificate (otherwise,
it is only compared with the IDr returned by the responder). The IDr sent by the initiator might otherwise
prevent the responder from finding a config if it has configured a different value for leftid.

left|rightid2 = <id>

Identity to use for the second authentication of the left participant (IKEv2 only).
Defaults to left|rightid.

left|rightikeport = <port>

UDP port the left participant uses for IKE communication. If unspecified, port 500 is used with the port
floating to 4500 if a NAT is detected or MOBIKE is enabled.
Specifying a local IKE port different from the default additionally requires a socket implementation that
listens to this port. Not supported for IKEv1 connections prior to 5.0.0.

left|rightprotoport = <protocol>/<port>

restrict the traffic selector to a single protocol and/or port. Since 5.1.0 this option is deprecated
as protocol/port information can be defined for each subnet directly in left|rightsubnet.

left|rightrsasigkey = <raw rsa public key> | <path to public key>

Since 5.1.0 a synonym for left|rightsigkey. Before that it denoted the left|right participant’s public key
for RSA signature authentication, in RFC 2537 format using hex (0x prefix) or base64 (0s prefix) encoding.
Also accepted was the path to a file containing the public key in PEM or DER encoding.

left|rightsigkey = <raw public key> | <path to public key>

Added with 5.1.0. The left|right participant’s public key for public key signature authentication, in PKCS#1
format using using hex (0x prefix) or base64 (0s prefix) encoding. With the optional dns: or ssh: prefix in front
of 0x or 0s, the public key is expected in either the RFC 3110 (not the full RR, only the RSA key part) or
RFC 4253 public key format, respectively.
Also accepted is the path to a file containing the public key in PEM, DER or SSH encoding. Both absolute paths or
paths relative to /etc/ipsec.d/certs are accepted.

left|rightsendcert = never | no | ifasked | always | yes

Accepted values are never or no, always or yes, and ifasked, the latter meaning that
the peer must send a certificate request (CR) payload in order to get a certificate in return.

leftsourceip = %config4 | %config6 | <ip address>

The internal source IP to use in a tunnel, also known as virtual IP.
If the value is one of the synonyms %config, %cfg, %modeconfig or %modecfg, an address (from
the tunnel address family) is requested from the peer.
Since 5.0.1 a comma-separated list is accepted to request multiple addresses, and with %config4 and
%config6 an address of the given address family will be requested explicitly.
If an IP address is configured, it will be requested from the responder, which is free to respond with a
different address.

rightsourceip = %config | <network>/<netmask> | <from>-<to> | %poolname

The internal source IP to use in a tunnel for the remote peer. If the value is config on the responder
side, the initiator must propose an address which is then echoed back. Also supported are address pools
expressed as <network>/<netmask> and <from>-<to> (since 5.2.2) or the use of an external IP address pool
using %poolname where poolname is the name of the IP address pool used for the lookup (see virtual IP for details).
Since 5.0.1 a comma-separated list of IP addresses / pools is accepted, for instance, to define pools of
different address families.

left|rightsubnet = <ip subnet>[[<proto/port>]][,…]

private subnet behind the left participant, expressed as network/netmask; if omitted, essentially assumed
to be left/32|128, signifying that the left|right end of the connection goes to the left|right participant only.
The configured subnets of the peers may differ, the protocol narrows it to the greatest common subnet.
Since 5.0.0 this is also done for IKEv1, but as this may lead to problems with other implementations,
make sure to configure identical subnets in such configurations.
IKEv2 supports multiple subnets separated by commas, IKEv1 only interprets the first subnet of such a definition,
unless the Cisco Unity extension plugin is enabled (available since 5.0.1). This is due to a limitation of the IKEv1
protocol, which only allows a single pair of subnets per CHILD_SA. So to tunnel several subnets a conn entry has
to be defined and brought up for each pair of subnets.

Since 5.1.0 the optional part after each subnet enclosed in square brackets specifies a protocol/port to restrict
the selector for that subnet. Examples: leftsubnet=10.0.0.1[tcp/http],10.0.0.2[6/80] or leftsubnet=fec1::1[udp],10.0.0.0/16[/53].
Instead of omitting either value %any can be used to the same effect, e.g. leftsubnet=fec1::1[udp/%any],10.0.0.0/16[%any/53].

Since 5.1.1, if the protocol is icmp or ipv6-icmp the port is interpreted as ICMP message type if it is less than 256,
or as type and code if it greater or equal to 256, with the type in the most significant 8 bits and the code in the
least significant 8 bits.

The port value can alternatively take the value %opaque for RFC 4301 OPAQUE selectors, or a numerical range
in the form 1024-65535. None of the kernel backends currently supports opaque or port ranges and uses %any
for policy installation instead.

Instead of specifying a subnet, %dynamic can be used to replace it with the IKE address, having the same effect
as omitting left|rightsubnet completely. Using %dynamic can be used to define multiple dynamic selectors,
each having a potentially different protocol/port definition.

left|rightupdown = <path>

what updown script to run to adjust routing and/or firewalling when the status of the connection
changes (default ipsec _updown). Relevant only locally, other end need not agree on it.
Charon uses the updown script to insert firewall rules only, since routing has been implemented directly
into the daemon.

IKEv2 Mediation Extension Parameters

The following parameters are relevant to IKEv2 Mediation Extension operation only.

mediation = yes | no

whether this connection is a mediation connection, ie. whether this connection is used to mediate other
connections. Mediation connections create no child SA. Acceptable values are no (the default) and yes.

mediated_by = <name>

the name of the connection to mediate this connection through. If given, the connection will be mediated
through the named mediation connection. The mediation connection must set mediation=yes.

me_peerid = <id>

ID as which the peer is known to the mediation server, ie. which the other end of this connection uses as
its leftid on its connection to the mediation server. This is the ID we request the mediation server to
mediate us with. If me_peerid is not given, the rightid of this connection will be used as peer ID.

Removed parameters (since 5.0.0)

auth = esp | ah

whether authentication should be done as part of ESP encryption, or separately using the AH protocol.
Only supported by the IKEv1 daemon pluto.

Since 5.1.1 the ah keyword can be used to configure AH with the charon IKE daemon.

pfs = yes | no

whether Perfect Forward Secrecy of keys is desired on the connection’s keying channel (with PFS,
penetration of the key-exchange protocol does not compromise keys negotiated earlier). IKEv2 always uses
PFS for IKE_SA rekeying whereas for CHILD_SA rekeying PFS is enforced by defining a Diffie-Hellman dhgroup
in the esp parameter. Since 5.0.0 the latter also applies to IKEv1 and this parameter has no effect anymore.

pfsgroup = <modp group>

defines a Diffie-Hellman group for perfect forward secrecy in IKEv1 Quick Mode differing from the DH group
used for IKEv1 Main Mode (IKEv1 pluto daemon only).
In current releases, DH groups are configured as part of the esp or ah proposals.

left|rightnexthop = %direct | %defaultroute | <ip address> | <fqdn>

This parameter is usually not needed any more because the NETKEY IPsec stack does not require
explicit routing entries for the traffic to be tunneled. If left|sourceip is used with IKEv1
then left|rightnexthop must still be set in order for the source routes to work properly.

left|rightsubnetwithin = <ip subnet>

the peer can propose any subnet or single IP address that fits within the range defined by
left|rightsubnetwithin. Is a synonym for left|rightsubnet since 5.0.0, as subnets are narrowed.

ipsec.secrets

strongSwan’s /etc/ipsec.secrets file contains an unlimited number of the following
types of secrets:

  • RSA defines an RSA private key
  • ECDSA defines an ECDSA private key
  • BLISS defines a BLISS Private key (since 5.2.2)
  • P12 defines a PKCS#12 container (since 5.1.0)
  • PSK defines a pre-shared key
  • EAP defines EAP credentials
  • NTLM defines NTLM credentials
  • XAUTH defines XAUTH credentials
  • PIN defines a smartcard PIN

Whitespace at the end of a line is ignored. At the start of a line or after whitespace, # and the following text up to the end of the line is treated as a comment.

An include directive causes the contents of the named file to be processed before continuing with the current file. The filename can contain wildcards, so every file with a matching name is processed. Includes may be nested to a modest depth (10, currently). If the filename doesn’t start with a /, the directory containing the current file is prepended to the name.

ID selectors

Each secret can be preceded by a list of optional ID selectors. The two parts are separated by a colon (:) that is surrounded by whitespace. If no ID selectors are specified the line must start with a colon.

A selector is an IP address, a Fully Qualified Domain Name, user@FQDN, %any or %any6. Since 5.4.0 IPv4 and IPv6 subnets in CIDR notation and address ranges (two addresses separated by a - without any spaces) may also be used as selectors. Refer to IdentityParsing for details on how identities are parsed.

Matching IDs with selectors is fairly straightforward: they have to be equal. In the case of a Road Warrior connection, if an equal match is not found for the Peer’s ID, and it is in the form of an IP address, a selector of %any will match the peer’s IP address if IPV4 and %any6 will match a the peer’s IP address if IPv6. Currently, the obsolete notation 0.0.0.0 may be used in place of %any.

When using IKEv1 an additional complexity arises in the case of authentication by preshared secret: the responder will need to look up the secret before the Peer’s ID payload has been decoded, so the ID used will be the IP address.

To authenticate a connection between two hosts, the entry that most specifically matches the host and peer IDs is used. An entry with no selectors will match any host and peer. More specifically, an entry with one selector will match a host and peer if the selector matches the host’s ID (the peer isn’t considered). Still more specifically, an entry with multiple selectors will match a host and peer if the host ID and peer ID each match one of the selectors. If the key is for an asymmetric authentication technique (i.e. a public key system such as RSA), an entry with multiple selectors will match a host and peer even if only the host ID matches a selector (it is presumed that the selectors are all identities of the host). It is acceptable for two entries to be the best match as long as they agree about the secret or private key.

Authentication by preshared secret requires that both systems find the identical secret (the secret is not actually transmitted by the IKE protocol). If both the host and peer appear in the selector list, the same entry will be suitable for both systems so verbatim copying between systems can be used. This naturally extends to larger groups sharing the same secret. Thus multiple-selector entries are best for PSK authentication.

Authentication by public key systems such as RSA requires that each host have its own private key. A host could reasonably use a different private keys for different interfaces and for different peers. But it would not be normal to share entries between systems. Thus no-selector and one-selector forms of entry often make sense for public key authentication.

Example

# /etc/ipsec.secrets – strongSwan IPsec secrets file 192.168.0.1 : PSK “v+NkxY9LLZvwj4qCC2o/gGrWDF2d21jL” : RSA moonKey.pem alice@strongswan.org : EAP “x3.dEhgN” carol : XAUTH “4iChxLT3” dave : XAUTH “ryftzG4A” # get secrets from other files include ipsec.*.secrets

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注