Manual:IP/IPsec: Difference between revisions

From MikroTik Wiki
Jump to navigation Jump to search
No edit summary
peer
Line 13: Line 13:
</p>
</p>


<h2>Encryption</h2>
<p>
<p>
IPsec uses two protocols to provide traffic security  
IPsec uses two protocols to provide traffic security  
Line 21: Line 20:
</ul>
</ul>


These protocols may be applied individually or in combination with each other, but most security requirements can be met through the use of ESP by itself.
These protocols may be applied individually or in combination with each other, but most security requirements can be met through the use of ESP by itself. Each of those protocols support [[transport mode]] and [[tunnel mode]]. In transport mode IpSec provides protection of next layer protocol, but in tunnel mode whole IP packet is protected (including IP header).
</p>
<p>
IpSec allows user to control security level by choosing which protocol to use (AH, ESP), tunnel or transport mode, what cryptographic algorithm to use and in what combination specified protocols and services will be used.
</p>
<p>
Because most of the security services provided by IPsec require the use of cryptographic keys, IPsec relies on a separate set of mechanisms for putting these keys in place (IKE).
</p>
</p>


====Internet Key Exchange====
<h2>Internet Key Exchange</h2>


The Internet Key Exchange (IKE) is a protocol that provides authenticated keying material for Internet Security Association and Key Management Protocol (ISAKMP) framework. There are other key exchange schemes that work with ISAKMP, but IKE is the most widely used one. Together they provide means for authentication of hosts and automatic management of security associations (SA).
The Internet Key Exchange (IKE) is a protocol that provides authenticated keying material for Internet Security Association and Key Management Protocol (ISAKMP) framework. There are other key exchange schemes that work with ISAKMP, but IKE is the most widely used one. Together they provide means for authentication of hosts and automatic management of security associations (SA).
Line 64: Line 69:
For manual keying you will have to configure policy and manual-sa entries.
For manual keying you will have to configure policy and manual-sa entries.


==Policy Settings==
<h2>Peer configuration</h2>
<p><b>Sub-menu:</b> <code>/ip ipsec peer</code></p>
<p>
Peer configuration settings are used to establish connections between IKE daemons (phase 1 configuration). This connection then will be used to negotiate keys and algorithms for SAs.
</p>
 
<p>
<table class="styled_table">
<tr>
  <th width="40%">Property</th>
  <th >Description</th>
</tr>
<tr>
    <td><var><b>address</b></var> (<em>IP[/Netmask]:port</em>; Default: <b>0.0.0.0/32:500</b>)</td>
    <td>Address prefix. If remote peer's address matches this prefix, then this peer configuration is used in authentication and establishment of phase 1. If several peer's addresses match several configuration entries, the most specific one (i.e. the one with largest netmask) will be used.</td>
</tr>
<tr>
    <td><var><b>auth-method</b></var> (<em>pre-shared-key | rsa-signature</em>; Default: <b>pre-shared-key</b>)</td>
    <td>Authentication method:
    <ul class="bullets">
        <li><var>pre-shared-key</var> - authenticate by a password (secret) string shared between the peers
        <li><var>rsa-signature</var> - authenticate using a pair of RSA certificates
    </ul>
    </td>
</tr>
<tr>
    <td><var><b>certificate</b></var> (<em>string</em>; Default: <b></b>)</td>
    <td>Name of a certificate on the local side (signing packets; the certificate must have private key). Applicable if RSA signature authentication method is used.</td>
</tr>
<tr>
    <td><var><b>dh-group</b></var> (<em>ec2n155 | ec2n185 | modp1024 | modp1536 | modp768</em>; Default: <b>modp1024</b>)</td>
    <td>[[#Diffie-Hellman Groups | Diffie-Hellman group]] (cipher strength)</td>
</tr>
<tr>
    <td><var><b>dpd-interval</b></var> (<em>disable-dpd | time</em>; Default: <b>disable-dpd</b>)</td>
    <td>Dead peer detection interval. If set to <var>disable-dpd</var>, dead peer detection will not be used.</td>
</tr>
<tr>
    <td><var><b>dpd-maximum-failures</b></var> (<em>integer: 1..100</em>; Default: <b>5</b>)</td>
    <td>Maximum count of failures until peer is considered to be dead.</td>
</tr>
<tr>
    <td><var><b>enc-algorithm</b></var> (<em>3des | aes-128 | aes-192 | aes-256 | des | blowfish | camilla</em>; Default: <b>3des</b>)</td>
    <td>Encryption algorithm. <var>blowfish, camilla</var> algorithms are supported starting from v4.5.</td>
</tr>
<tr>
    <td><var><b>exchange-mode</b></var> (<em>aggressive | base | main</em>; Default: <b>main</b>)</td>
    <td>Different ISAKMP phase 1 exchange modes according to RFC 2408. Do not use other modes then main unless you know what you are doing.</td>
</tr>
<tr>
    <td><var><b>generate-policy</b></var> (<em>yes | no</em>; Default: <b>no</b>)</td>
    <td>Allow this peer to establish SA for non-existing policies. Such policies are created dynamically for the lifetime of SA. This way it is possible, for example, to create IPsec secured [[L2TP]] tunnels, or any other setup where remote peer's IP address is not known at the configuration time.</td>
</tr>
<tr>
    <td><var><b>hash-algorithm</b></var> (<em>md5 | sha1</em>; Default: <b>md5</b>)</td>
    <td>Hashing algorithm. SHA (Secure Hash Algorithm) is stronger, but slower.</td>
</tr>
<tr>
    <td><var><b>lifebytes</b></var> (<em>Integer: 0..4294967295</em>; Default: <b>0</b>)</td>
    <td>Phase 1 lifetime: specifies how much bytes can be transferred before SA is discarded. If set to <b>0</b> SA will not be discarded due to byte count excess.</td>
</tr>
<tr>
    <td><var><b>lifetime</b></var> (<em>time</em>; Default: <b>1d</b>)</td>
    <td>Phase 1 lifetime: specifies how long the SA will be valid</td>
</tr>
<tr>
    <td><var><b>nat-traversal</b></var> (<em>yes | no</em>; Default: <b>no</b>)</td>
    <td>Use Linux NAT-T mechanism to solve IPsec incompatibility with NAT routers inbetween IPsec peers. This can only be used with ESP protocol (AH is not supported by design, as it signes the complete packet, including IP header, which is changed by NAT, rendering AH signature invalid). The method encapsulates IPsec ESP traffic into UDP streams in order to overcome some minor issues that made ESP incompatible with NAT.</td>
</tr>
<tr>
    <td><var><b>proposal-check</b></var> (<em>claim | exact | obey | strict</em>; Default: <b>obey</b>)</td>
    <td>Phase 2 lifetime check logic:
    <ul class="bullets">
        <li><var>claim</var> - take shortest of proposed and configured lifetimes and notify initiator about it
        <li><var>exact</var> -  require lifetimes to be the same
        <li><var>obey</var> -  accept whatever is sent by an initiator
        <li><var>strict</var> -  if proposed lifetime is longer than the default then reject proposal otherwise accept proposed lifetime
    </ul>
    </td>
</tr>
<tr>
    <td><var><b>remote-certificate</b></var> (<em>string</em>; Default: <b></b>)</td>
    <td>Name of a certificate for authenticating the remote side (validating packets; no private key required). Applicable if RSA signature authentication method is used</td>
</tr>
<tr>
    <td><var><b>secret</b></var> (<em>string</em>; Default: <b>""</b>)</td>
    <td>Secret string (in case pre-shared key authentication is used). If it starts with '0x', it is parsed as a hexadecimal value</td>
</tr>
<tr>
    <td><var><b>send-initial-contact</b></var> (<em>yes | no</em>; Default: <b>yes</b>)</td>
    <td>Specifies whether to send initial IKE information or wait for remote side.</td>
</tr>
</table>
</p>
 
 


{{...}}
{{...}}

Revision as of 15:02, 17 December 2009

Applies to RouterOS: v4.5

Summary

Sub-menu: /ip ipsec
Package required: security
Standards: RFC 4301


Internet Protocol Security (IPsec) is a set of protocols to secure packet exchange over IP network. Each IP packet is authenticated and encrypted by one of various supported encryption and authentication algorithms.

IPsec uses two protocols to provide traffic security

  • Authentication Header (AH) RFC 4302
  • Encapsulating Security Payload (ESP) RFC 4303

These protocols may be applied individually or in combination with each other, but most security requirements can be met through the use of ESP by itself. Each of those protocols support transport mode and tunnel mode. In transport mode IpSec provides protection of next layer protocol, but in tunnel mode whole IP packet is protected (including IP header).

IpSec allows user to control security level by choosing which protocol to use (AH, ESP), tunnel or transport mode, what cryptographic algorithm to use and in what combination specified protocols and services will be used.

Because most of the security services provided by IPsec require the use of cryptographic keys, IPsec relies on a separate set of mechanisms for putting these keys in place (IKE).

Internet Key Exchange

The Internet Key Exchange (IKE) is a protocol that provides authenticated keying material for Internet Security Association and Key Management Protocol (ISAKMP) framework. There are other key exchange schemes that work with ISAKMP, but IKE is the most widely used one. Together they provide means for authentication of hosts and automatic management of security associations (SA).

Most of the time IKE daemon is doing nothing. There are two possible situations when it is activated:

There is some traffic caught by a policy rule which needs to become encrypted or authenticated, but the policy doesn't have any SAs. The policy notifies IKE daemon about that, and IKE daemon initiates connection to remote host. IKE daemon responds to remote connection. In both cases, peers establish connection and execute 2 phases:

  • Phase 1 - The peers agree upon algorithms they will use in the following IKE messages and authenticate. The keying material used to derive keys for all SAs and to protect following ISAKMP exchanges between hosts is generated also.
  • Phase 2 - The peers establish one or more SAs that will be used by IPsec to encrypt data. All SAs established by IKE daemon will have lifetime values (either limiting time, after which SA will become invalid, or amount of data that can be encrypted by this SA, or both).

There are two lifetime values - soft and hard. When SA reaches it's soft lifetime treshold, the IKE daemon receives a notice and starts another phase 2 exchange to replace this SA with fresh one. If SA reaches hard lifetime, it is discarded.

IKE can optionally provide a Perfect Forward Secrecy (PFS), which is a property of key exchanges, that, in turn, means for IKE that compromising the long term phase 1 key will not allow to easily gain access to all IPsec data that is protected by SAs established through this phase 1. It means an additional keying material is generated for each phase 2.

Generation of keying material is computationally very expensive. Exempli gratia, the use of modp8192 group can take several seconds even on very fast computer. It usually takes place once per phase 1 exchange, which happens only once between any host pair and then is kept for long time. PFS adds this expensive operation also to each phase 2 exchange.

Diffie-Hellman Groups

Diffie-Hellman (DH) key exchange protocol allows two parties without any initial shared secret to create one securely. The following Modular Exponential (MODP) and Elliptic Curve (EC2N) Diffie-Hellman (also known as "Oakley") Groups are supported:

Diffie-Hellman GroupNameReference
Group 1768 bit MODP groupRFC 2409
Group 21024 bits MODP groupRFC 2409
Group 3EC2N group on GP(2^155)RFC 2409
Group 4EC2N group on GP(2^185)RFC 2409
Group 51536 bits MODP groupRFC 3526

IKE Traffic

To avoid problems with IKE packets hit some SPD rule and require to encrypt it with not yet established SA (that this packet perhaps is trying to establish), locally originated packets with UDP source port 500 are not processed with SPD. The same way packets with UDP destination port 500 that are to be delivered locally are not processed in incoming policy check.

Setup Procedure

To get IPsec to work with automatic keying using IKE-ISAKMP you will have to configure policy, peer and proposal (optional) entries.

For manual keying you will have to configure policy and manual-sa entries.

Peer configuration

Sub-menu: /ip ipsec peer

Peer configuration settings are used to establish connections between IKE daemons (phase 1 configuration). This connection then will be used to negotiate keys and algorithms for SAs.

Property Description
address (IP[/Netmask]:port; Default: 0.0.0.0/32:500) Address prefix. If remote peer's address matches this prefix, then this peer configuration is used in authentication and establishment of phase 1. If several peer's addresses match several configuration entries, the most specific one (i.e. the one with largest netmask) will be used.
auth-method (pre-shared-key | rsa-signature; Default: pre-shared-key) Authentication method:
  • pre-shared-key - authenticate by a password (secret) string shared between the peers
  • rsa-signature - authenticate using a pair of RSA certificates
certificate (string; Default: ) Name of a certificate on the local side (signing packets; the certificate must have private key). Applicable if RSA signature authentication method is used.
dh-group (ec2n155 | ec2n185 | modp1024 | modp1536 | modp768; Default: modp1024) Diffie-Hellman group (cipher strength)
dpd-interval (disable-dpd | time; Default: disable-dpd) Dead peer detection interval. If set to disable-dpd, dead peer detection will not be used.
dpd-maximum-failures (integer: 1..100; Default: 5) Maximum count of failures until peer is considered to be dead.
enc-algorithm (3des | aes-128 | aes-192 | aes-256 | des | blowfish | camilla; Default: 3des) Encryption algorithm. blowfish, camilla algorithms are supported starting from v4.5.
exchange-mode (aggressive | base | main; Default: main) Different ISAKMP phase 1 exchange modes according to RFC 2408. Do not use other modes then main unless you know what you are doing.
generate-policy (yes | no; Default: no) Allow this peer to establish SA for non-existing policies. Such policies are created dynamically for the lifetime of SA. This way it is possible, for example, to create IPsec secured L2TP tunnels, or any other setup where remote peer's IP address is not known at the configuration time.
hash-algorithm (md5 | sha1; Default: md5) Hashing algorithm. SHA (Secure Hash Algorithm) is stronger, but slower.
lifebytes (Integer: 0..4294967295; Default: 0) Phase 1 lifetime: specifies how much bytes can be transferred before SA is discarded. If set to 0 SA will not be discarded due to byte count excess.
lifetime (time; Default: 1d) Phase 1 lifetime: specifies how long the SA will be valid
nat-traversal (yes | no; Default: no) Use Linux NAT-T mechanism to solve IPsec incompatibility with NAT routers inbetween IPsec peers. This can only be used with ESP protocol (AH is not supported by design, as it signes the complete packet, including IP header, which is changed by NAT, rendering AH signature invalid). The method encapsulates IPsec ESP traffic into UDP streams in order to overcome some minor issues that made ESP incompatible with NAT.
proposal-check (claim | exact | obey | strict; Default: obey) Phase 2 lifetime check logic:
  • claim - take shortest of proposed and configured lifetimes and notify initiator about it
  • exact - require lifetimes to be the same
  • obey - accept whatever is sent by an initiator
  • strict - if proposed lifetime is longer than the default then reject proposal otherwise accept proposed lifetime
remote-certificate (string; Default: ) Name of a certificate for authenticating the remote side (validating packets; no private key required). Applicable if RSA signature authentication method is used
secret (string; Default: "") Secret string (in case pre-shared key authentication is used). If it starts with '0x', it is parsed as a hexadecimal value
send-initial-contact (yes | no; Default: yes) Specifies whether to send initial IKE information or wait for remote side.


(needs editing)