1.\" $OpenBSD: iked.conf.5,v 1.84 2021/02/13 16:14:12 tobhe Exp $ 2.\" 3.\" Copyright (c) 2010 - 2014 Reyk Floeter <reyk@openbsd.org> 4.\" Copyright (c) 2004 Mathieu Sauve-Frankel All rights reserved. 5.\" 6.\" Permission to use, copy, modify, and distribute this software for any 7.\" purpose with or without fee is hereby granted, provided that the above 8.\" copyright notice and this permission notice appear in all copies. 9.\" 10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" 18.Dd $Mdocdate: February 13 2021 $ 19.Dt IKED.CONF 5 20.Os 21.Sh NAME 22.Nm iked.conf 23.Nd IKEv2 configuration file 24.Sh DESCRIPTION 25.Nm 26is the configuration file for 27.Xr iked 8 , 28the Internet Key Exchange version 2 (IKEv2) daemon for IPsec. 29IPsec itself is a pair of protocols: 30Encapsulating Security Payload (ESP), 31which provides integrity and confidentiality; 32and Authentication Header (AH), 33which provides integrity. 34The IPsec protocol itself is described in 35.Xr ipsec 4 . 36.Pp 37In its most basic form, a flow is established between hosts and/or 38networks, and then Security Associations (SA) are established, 39which detail how the desired protection will be achieved. 40IPsec uses flows to determine whether to apply security services to an 41IP packet or not. 42.Xr iked 8 43is used to set up flows and establish SAs automatically, 44by specifying 45.Sq ikev2 46policies in 47.Nm 48(see 49.Sx AUTOMATIC KEYING POLICIES , 50below). 51.Pp 52Alternative methods of setting up flows and SAs are also possible 53using manual keying or automatic keying using the older ISAKMP/Oakley 54a.k.a. IKEv1 protocol. 55Manual keying is not recommended, but can be convenient for quick 56setups and testing. 57See 58.Xr ipsec.conf 5 59and 60.Xr isakmpd 8 61for more information about manual keying and ISAKMP support. 62.Sh IKED.CONF FILE FORMAT 63.Nm 64is divided into three main sections: 65.Bl -tag -width xxxx 66.It Sy Macros 67User-defined macros may be defined and used later, simplifying the 68configuration file. 69.It Sy Global Configuration 70Global settings for 71.Xr iked 8 . 72.It Sy Automatic Keying Policies 73Policies to set up IPsec flows and SAs automatically. 74.El 75.Pp 76Lines beginning with 77.Sq # 78and empty lines are regarded as comments, 79and ignored. 80Lines may be split using the 81.Sq \e 82character. 83.Pp 84Argument names not beginning with a letter, digit, or underscore 85must be quoted. 86.Pp 87Addresses can be specified in CIDR notation (matching netblocks), 88as symbolic host names, interface names, or interface group names. 89.Pp 90Additional configuration files can be included with the 91.Ic include 92keyword, for example: 93.Bd -literal -offset indent 94include "/etc/macros.conf" 95.Ed 96.Sh MACROS 97Macros can be defined that will later be expanded in context. 98Macro names must start with a letter, digit, or underscore, 99and may contain any of those characters. 100Macro names may not be reserved words (for example 101.Ic flow , 102.Ic from , 103.Ic esp ) . 104Macros are not expanded inside quotes. 105.Pp 106For example: 107.Bd -literal -offset indent 108remote_gw = "192.168.3.12" 109ikev2 esp from 192.168.7.0/24 to 192.168.8.0/24 peer $remote_gw 110.Ed 111.Sh GLOBAL CONFIGURATION 112Here are the settings that can be set globally: 113.Bl -tag -width xxxx 114.It Ic set active 115Set 116.Xr iked 8 117to global active mode. 118In active mode the per-policy 119.Ar mode 120setting is respected. 121.Xr iked 8 122will initiate policies set to 123.Ar active 124and wait for incoming requests for policies set to 125.Ar passive . 126This is the default. 127.It Ic set passive 128Set 129.Xr iked 8 130to global passive mode. 131In passive mode no packets are sent to peers and no connections are 132initiated by 133.Xr iked 8 , 134even for 135.Ar active 136policies. 137This option is used for setups using 138.Xr sasyncd 8 139and 140.Xr carp 4 141to provide redundancy. 142.Xr iked 8 143will run in passive mode until sasyncd has determined that the host 144is the master and can switch to active mode. 145.It Ic set couple 146Load the negotiated security associations (SAs) and flows into the kernel. 147This is the default. 148.It Ic set decouple 149Don't load the negotiated SAs and flows from the kernel. 150This mode is only useful for testing and debugging. 151.It Ic set dpd_check_interval Ar time 152Specify the liveness check interval, in seconds. 153Setting 154.Ar time 155to 0 disables DPD. 156The default value is 60 seconds. 157.It Ic set enforcesingleikesa 158Allow only a single active IKE SA for each 159.Ic dstid . 160When a new SA with the same 161.Ic dstid 162is established, it replaces the old SA. 163.It Ic set noenforcesingleikesa 164Don't limit the number of IKE SAs per 165.Ic dstid . 166This is the default. 167.It Ic set fragmentation 168Enable IKEv2 Message Fragmentation (RFC 7383) support. 169This allows IKEv2 to operate in environments that might block IP fragments. 170.It Ic set nofragmentation 171Disables IKEv2 Message Fragmentation support. 172This is the default. 173.It Ic set mobike 174Enable MOBIKE (RFC 4555) support. 175This is the default. 176MOBIKE allows the peer IP address to be changed for IKE and IPsec SAs. 177Currently 178.Xr iked 8 179only supports MOBIKE when acting as a responder. 180.It Ic set nomobike 181Disables MOBIKE support. 182.It Ic set cert_partial_chain 183Allow partial certificate chain if at least one certificate is a trusted CA from 184.Pa /etc/iked/ca/ . 185.It Ic set ocsp Ar URL Op Ic tolerate Ar time Op Ic maxage Ar time 186Enable OCSP and set the fallback URL of the OCSP responder. 187This fallback will be used if the trusted CA from 188.Pa /etc/iked/ca/ 189does not have an OCSP-URL extension. 190Please note that the matching responder certificates 191have to be placed in 192.Pa /etc/iked/ocsp/responder.crt . 193.Pp 194The optional 195.Ic tolerate 196parameter specifies how much the OCSP response attribute 197.Sq thisUpdate 198may be in the future and how much 199.Sq nextUpdate 200may be in the past, with respect to the local time. 201The optional 202.Ic maxage 203parameter specifies how much 204.Sq thisUpdate 205may be in the past. 206If 207.Ic tolerate 208is set to 0 then the times are not verified at all. 209This is the default setting. 210.It Ic user Ar name password 211.Xr iked 8 212supports user-based authentication by tunneling the Extensible 213Authentication Protocol (EAP) over IKEv2. 214In its most basic form, the users will be authenticated against a 215local, integrated password database that is configured with the 216.Ic user 217lines in 218.Nm 219and the 220.Ar name 221and 222.Ar password 223arguments. 224Note that the password has to be specified in plain text which is 225required to support different challenge-based EAP methods like 226EAP-MD5 or EAP-MSCHAPv2. 227.El 228.Sh AUTOMATIC KEYING POLICIES 229This section is used to configure policies that will be used by 230.Xr iked 8 231to set up flows and SAs automatically. 232Some examples of setting up automatic keying: 233.Bd -literal -offset 3n 234# Set up a VPN: 235# First between the gateway machines 192.168.3.1 and 192.168.3.2 236# Second between the networks 10.1.1.0/24 and 10.1.2.0/24 237ikev2 esp from 192.168.3.1 to 192.168.3.2 238ikev2 esp from 10.1.1.0/24 to 10.1.2.0/24 peer 192.168.3.2 239.Ed 240.Pp 241For incoming connections from remote peers, the policies are evaluated 242in sequential order, from first to last. 243The last matching policy decides what action is taken; if no policy matches 244the connection, the default action is to ignore the connection attempt or 245to use the 246.Ar default 247policy, if set. 248Please also see the 249.Sx EXAMPLES 250section for a detailed example of the policy evaluation. 251.Pp 252The first time an IKEv2 connection matches a policy, an IKE SA is 253created; for subsequent packets the connection is identified by the 254IKEv2 parameters that are stored in the SA without evaluating any 255policies. 256After the connection is closed or times out, the IKE SA is 257automatically removed. 258.Pp 259The commands are as follows: 260.Bl -tag -width xxxx 261.It Xo 262.Ic ikev2 263.Op Ar name 264.Xc 265The mandatory 266.Ic ikev2 267keyword will identify an IKEv2 automatic keying policy. 268.Ar name 269is an optional arbitrary string identifying the policy. 270The name should only occur once in 271.Nm 272or any included files. 273If omitted, 274a name will be generated automatically for the policy. 275.It Op Ar eval 276The 277.Ar eval 278option modifies the policy evaluation for this policy. 279It can be one of 280.Ar quick , 281.Ar skip 282or 283.Ar default . 284If a new incoming connection matches a policy with the 285.Ar quick 286option set, that policy is considered the last matching policy, 287and evaluation of subsequent policies is skipped. 288The 289.Ar skip 290option will disable evaluation of this policy for incoming connections. 291The 292.Ar default 293option sets the default policy and should only be specified once. 294.It Op Ar mode 295.Ar mode 296specifies the IKEv2 mode to use: 297one of 298.Ar passive 299or 300.Ar active . 301When 302.Ar passive 303is specified, 304.Xr iked 8 305will not immediately start negotiation of this tunnel, but wait for an incoming 306request from the remote peer. 307When 308.Ar active 309is specified, negotiation will be started at once. 310If omitted, 311.Ar passive 312mode will be used. 313.It Op Ar ipcomp 314The keyword 315.Ar ipcomp 316specifies that 317.Xr ipcomp 4 , 318the IP Payload Compression protocol, is negotiated in addition to encapsulation. 319The optional compression is applied before packets are encapsulated. 320IPcomp must be enabled in the kernel: 321.Pp 322.Dl # sysctl net.inet.ipcomp.enable=1 323.It Op Ar tmode 324.Ar tmode 325describes the encapsulation mode to be used. 326Possible modes are 327.Ar tunnel 328and 329.Ar transport ; 330the default is 331.Ar tunnel . 332.It Op Ar encap 333.Ar encap 334specifies the encapsulation protocol to be used. 335Possible protocols are 336.Ar esp 337and 338.Ar ah ; 339the default is 340.Ar esp . 341.It Op Ar af 342This policy only applies to endpoints of the specified address family 343which can be either 344.Ar inet 345or 346.Ar inet6 . 347Note that this only matters for IKEv2 endpoints and does not 348restrict the traffic selectors to negotiate flows with different 349address families, e.g. IPv6 flows negotiated by IPv4 endpoints. 350.It Ic proto Ar protocol 351The optional 352.Ic proto 353parameter restricts the flow to a specific IP protocol. 354Common protocols are 355.Xr icmp 4 , 356.Xr tcp 4 , 357and 358.Xr udp 4 . 359For a list of all the protocol name to number mappings used by 360.Xr iked 8 , 361see the file 362.Pa /etc/protocols . 363.It Ic rdomain Ar number 364Specify a different routing domain for unencrypted traffic. 365The resulting IPsec SAs will match outgoing packets in the specified 366.Ic rdomain Ar number 367and move the encrypted packets to the rdomain the 368.Xr iked 8 369instance is running in. 370Vice versa, incoming 371.Xr ipsec 4 372traffic is moved to 373.Ic rdomain Ar number 374after decryption. 375.It Xo 376.Ic from Ar src 377.Op Ic port Ar sport 378.Op Pq Ar srcnat 379.Ic to Ar dst 380.Op Ic port Ar dport 381.Xc 382Specify one or more traffic selectors for this policy which will be 383used to negotiate the IPsec flows between the IKEv2 peers. 384During the negotiation, the peers may decide to narrow a flow to a 385subset of the configured traffic selector networks to match the 386policies on each side. 387.Pp 388Each traffic selector will apply for packets with source address 389.Ar src 390and destination address 391.Ar dst . 392If the 393.Ar src 394argument specifies a fictional source ID, 395the 396.Ar srcnat 397parameter can be used to specify the actual source address. 398This can be used in outgoing NAT/BINAT scenarios as described below. 399The keyword 400.Ar any 401will match any address (i.e. 0.0.0.0/0 and ::/0). 402If the 403.Ic config address 404option is specified, the 405.Ar dynamic 406keyword can be used to create flows from or to the dynamically 407assigned address. 408.Pp 409The optional 410.Ic port 411modifiers restrict the traffic selectors to the specified ports. 412They are only valid in conjunction with the 413.Xr tcp 4 414and 415.Xr udp 4 416protocols. 417Ports can be specified by number or by name. 418For a list of all port name to number mappings used by 419.Xr ipsecctl 8 , 420see the file 421.Pa /etc/services . 422.It Ic local Ar localip Ic peer Ar remote 423The 424.Ic local 425parameter specifies the address or FQDN of the local endpoint. 426Unless the gateway is multi-homed or uses address aliases, 427this option is generally not needed. 428.Pp 429The 430.Ic peer 431parameter specifies the address or FQDN of the remote endpoint. 432For host-to-host connections where 433.Ar dst 434is identical to 435.Ar remote , 436this option is generally not needed as it will be set to 437.Ar dst 438automatically. 439If it is not specified or if the keyword 440.Ar any 441is given, the default peer is used. 442.It Xo 443.Ic ikesa 444.Ic auth Ar algorithm 445.Ic enc Ar algorithm 446.Ic prf Ar algorithm 447.Ic group Ar group 448.Xc 449These parameters define the mode and cryptographic transforms to be 450used for the IKE SA negotiation, also known as phase 1. 451The IKE SA will be used to authenticate the machines and to set up an 452encrypted channel for the IKEv2 protocol. 453.Pp 454Possible values for 455.Ic auth , 456.Ic enc , 457.Ic prf , 458.Ic group , 459and the default proposals are described below in 460.Sx CRYPTO TRANSFORMS . 461If omitted, 462.Xr iked 8 463will use the default proposals for the IKEv2 protocol. 464.Pp 465The keyword 466.Ic ikesa 467can be used multiple times as a delimiter between IKE SA proposals. 468The order of the proposals depend on the order in the configuration. 469The keywords 470.Ic auth , 471.Ic enc , 472.Ic prf 473and 474.Ic group 475can be used multiple times within a single proposal to configure 476multiple crypto transforms. 477.It Xo 478.Ic childsa 479.Ic auth Ar algorithm 480.Ic enc Ar algorithm 481.Ic group Ar group 482.Ic esn 483.Xc 484These parameters define the cryptographic transforms to be used for 485the Child SA negotiation, also known as phase 2. 486Each Child SA will be used to negotiate the actual IPsec SAs. 487The initial Child SA is always negotiated with the initial IKEv2 key 488exchange; additional Child SAs may be negotiated with additional 489Child SA key exchanges for an established IKE SA. 490.Pp 491Possible values for 492.Ic auth , 493.Ic enc , 494.Ic group , 495.Ic esn , 496and the default proposals are described below in 497.Sx CRYPTO TRANSFORMS . 498If omitted, 499.Xr iked 8 500will use the default proposals for the ESP or AH protocol. 501.Pp 502The 503.Ic group 504option will only be used to enable Perfect Forward Secrecy (PFS) 505for additional Child SAs exchanges that are not part of the initial 506key exchange. 507.Pp 508The keyword 509.Ic childsa 510can be used multiple times as a delimiter between Child SA proposals. 511The order of the proposals depend on the order in the configuration. 512The keywords 513.Ic auth , 514.Ic enc 515and 516.Ic group 517can be used multiple times within a single proposal to configure 518multiple crypto transforms. 519.It Ic srcid Ar string Ic dstid Ar string 520.Ic srcid 521defines an ID of type 522.Dq FQDN , 523.Dq ASN1_DN , 524.Dq IPV4 , 525.Dq IPV6 , 526or 527.Dq UFQDN 528that will be used by 529.Xr iked 8 530as the identity of the local peer. 531If the argument is an email address (reyk@example.com), 532.Xr iked 8 533will use UFQDN as the ID type. 534The ASN1_DN type will be used if the string starts with a slash 535.Sq / 536(/C=DE/../CN=10.0.0.1/emailAddress=reyk@example.com). 537If the argument is an IPv4 address or a compressed IPv6 address, 538the ID types IPV4 or IPV6 will be used. 539Anything else is considered to be an FQDN. 540.Pp 541If 542.Ic srcid 543is omitted, 544the default is to use the hostname of the local machine, 545see 546.Xr hostname 1 547to set or print the hostname. 548.Pp 549.Ic dstid 550is similar to 551.Ic srcid , 552but instead specifies the ID to be used 553by the remote peer. 554.It Ic ikelifetime Ar time 555The optional 556.Ic ikelifetime 557parameter defines the IKE SA expiration timeout by the 558.Ar time 559SA was created. 560A zero value disables active IKE SA rekeying. 561This is the default. 562.Pp 563The accepted format of the 564.Ar time 565specification is described below. 566.It Ic lifetime Ar time Op Ic bytes Ar bytes 567The optional 568.Ic lifetime 569parameter defines the Child SA expiration timeout by the 570.Ar time 571SA was in use and by the number of 572.Ar bytes 573that were processed using the SA. 574Default values are 3 hours and 512 megabytes which means that SA will be 575rekeyed before reaching the time limit or 512 megabytes of data 576will pass through. 577Zero values disable rekeying. 578.Pp 579Several unit specifiers are recognized (ignoring case): 580.Ql m 581and 582.Ql h 583for minutes and hours, and 584.Ql K , 585.Ql M 586and 587.Ql G 588for kilo-, mega- and gigabytes accordingly. 589.Pp 590Please note that rekeying must happen at least several times a day as 591IPsec security heavily depends on frequent key renewals. 592.It Op Ar ikeauth 593Specify a method to be used to authenticate the remote peer. 594.Xr iked 8 595will automatically determine a method based on public keys or certificates 596configured for the peer. 597.Ar ikeauth 598can be used to override this behaviour. 599Non-psk modes will require setting up certificates and RSA or ECDSA public 600keys; see 601.Xr iked 8 602for more information. 603.Pp 604.Bl -tag -width $domain -compact -offset indent 605.It Ic eap Ar type 606Use EAP to authenticate the initiator. 607The only supported EAP 608.Ar type 609is currently 610.Ar MSCHAP-V2 . 611The responder will use RSA public key authentication. 612.It Ic ecdsa256 613Use ECDSA with a 256-bit elliptic curve key and SHA2-256 for authentication. 614.It Ic ecdsa384 615Use ECDSA with a 384-bit elliptic curve key and SHA2-384 for authentication. 616.It Ic ecdsa521 617Use ECDSA with a 521-bit elliptic curve key and SHA2-512 for authentication. 618.It Ic psk Ar string 619Use a pre-shared key 620.Ar string 621or hex value (starting with 0x) for authentication. 622.It Ic rfc7427 623Only use RFC 7427 signatures for authentication. 624RFC 7427 signatures currently only support SHA2-256 as the hash. 625.It Ic rsa 626Use RSA public key authentication with SHA1 as the hash. 627.El 628.Pp 629The default is to allow any signature authentication. 630.It Ic config Ar option address 631Send one or more optional configuration payloads (CP) to the peer. 632The configuration 633.Ar option 634can be one of the following with the expected address format: 635.Pp 636.Bl -tag -width Ds -compact -offset indent 637.It Ic address Ar address 638Assign a static address on the internal network. 639.It Ic address Ar address/prefix 640Assign a dynamic address on the internal network. 641The address will be assigned from an address pool with the size specified by 642.Ar prefix . 643.It Ic netmask Ar netmask 644The IPv4 netmask of the internal network. 645.It Ic name-server Ar address 646The DNS server address within the internal network. 647.It Ic netbios-server Ar address 648The NetBIOS name server (WINS) within the internal network. 649This option is provided for compatibility with legacy clients. 650.It Ic dhcp-server Ar address 651The address of an internal DHCP server for further configuration. 652.It Ic protected-subnet Ar address/prefix 653The address of an additional IPv4 or IPv6 subnet reachable over the 654gateway. 655This option is used to notify the peer of a subnet behind the gateway (that 656might require a second SA). 657Networks specified in this SA's "from" or "to" options do not need to be 658included. 659.It Ic access-server Ar address 660The address of an internal remote access server. 661.El 662.It Ic iface Ar interface 663Configure requested addresses and routes on the specified 664.Ar interface . 665.It Ic tag Ar string 666Add a 667.Xr pf 4 668tag to all packets of IPsec SAs created for this connection. 669This will allow matching packets for this connection by defining 670rules in 671.Xr pf.conf 5 672using the 673.Cm tagged 674keyword. 675.Pp 676The following variables can be used in tags to include information 677from the remote peer on runtime: 678.Pp 679.Bl -tag -width $domain -compact -offset indent 680.It Ar $id 681The 682.Ic dstid 683that was proposed by the remote peer to identify itself. 684It will be expanded to 685.Ar id-value , 686e.g.\& 687.Ar FQDN/foo.example.com . 688To limit the size of the derived tag, 689.Xr iked 8 690will extract the common name 691.Sq CN= 692from ASN1_DN IDs, for example 693.Ar ASN1_ID//C=DE/../CN=10.1.1.1/.. 694will be expanded to 695.Ar 10.1.1.1 . 696.It Ar $eapid 697For a connection using EAP, the identity (username) used by the remote peer. 698.It Ar $domain 699Extract the domain from IDs of type FQDN, UFQDN or ASN1_DN. 700.It Ar $name 701The name of the IKEv2 policy that was configured in 702.Nm 703or automatically generated by 704.Xr iked 8 . 705.El 706.Pp 707For example, if the ID is 708.Ar FQDN/foo.example.com 709or 710.Ar UFQDN/user@example.com , 711.Dq ipsec-$domain 712expands to 713.Dq ipsec-example.com . 714The variable expansion for the 715.Ar tag 716directive occurs only at runtime (not when the file is parsed) 717and must be quoted, or it will be interpreted as a macro. 718.It Ic tap Ar interface 719Send the decapsulated IPsec traffic to the specified 720.Xr enc 4 721.Ar interface 722instead of 723.Ar enc0 724for filtering and monitoring. 725The traffic will be blocked if the specified 726.Ar interface 727does not exist. 728.El 729.Sh PACKET FILTERING 730IPsec traffic appears unencrypted on the 731.Xr enc 4 732interface 733and can be filtered accordingly using the 734.Ox 735packet filter, 736.Xr pf 4 . 737The grammar for the packet filter is described in 738.Xr pf.conf 5 . 739.Pp 740The following components are relevant to filtering IPsec traffic: 741.Bl -ohang -offset indent 742.It external interface 743Interface for IKE traffic and encapsulated IPsec traffic. 744.It proto udp port 500 745IKE traffic on the external interface. 746.It proto udp port 4500 747IKE NAT-Traversal traffic on the external interface. 748.It proto ah | esp 749Encapsulated IPsec traffic 750on the external interface. 751.It enc0 752Default interface for outgoing traffic before it's been encapsulated, 753and incoming traffic after it's been decapsulated. 754State on this interface should be interface bound; 755see 756.Xr enc 4 757for further information. 758.It proto ipencap 759[tunnel mode only] 760IP-in-IP traffic flowing between gateways 761on the enc0 interface. 762.It tagged ipsec-example.org 763Match traffic of IPsec SAs using the 764.Ic tag 765keyword. 766.El 767.Pp 768If the filtering rules specify to block everything by default, 769the following rule 770would ensure that IPsec traffic never hits the packet filtering engine, 771and is therefore passed: 772.Bd -literal -offset indent 773set skip on enc0 774.Ed 775.Pp 776In the following example, all traffic is blocked by default. 777IPsec-related traffic from gateways {192.168.3.1, 192.168.3.2} and 778networks {10.0.1.0/24, 10.0.2.0/24} is permitted. 779.Bd -literal -offset indent 780block on ix0 781block on enc0 782 783pass in on ix0 proto udp from 192.168.3.2 to 192.168.3.1 \e 784 port {500, 4500} 785pass out on ix0 proto udp from 192.168.3.1 to 192.168.3.2 \e 786 port {500, 4500} 787 788pass in on ix0 proto esp from 192.168.3.2 to 192.168.3.1 789pass out on ix0 proto esp from 192.168.3.1 to 192.168.3.2 790 791pass in on enc0 proto ipencap from 192.168.3.2 to 192.168.3.1 \e 792 keep state (if-bound) 793pass out on enc0 proto ipencap from 192.168.3.1 to 192.168.3.2 \e 794 keep state (if-bound) 795pass in on enc0 from 10.0.2.0/24 to 10.0.1.0/24 \e 796 keep state (if-bound) 797pass out on enc0 from 10.0.1.0/24 to 10.0.2.0/24 \e 798 keep state (if-bound) 799.Ed 800.Pp 801.Xr pf 4 802has the ability to filter IPsec-related packets 803based on an arbitrary 804.Em tag 805specified within a ruleset. 806The tag is used as an internal marker 807which can be used to identify the packets later on. 808This could be helpful, 809for example, 810in scenarios where users are connecting in from differing IP addresses, 811or to support queue-based bandwidth control, 812since the enc0 interface does not support it. 813.Pp 814The following 815.Xr pf.conf 5 816fragment uses queues for all IPsec traffic with special 817handling for developers and employees: 818.Bd -literal -offset indent 819queue std on ix0 bandwidth 100M 820queue deflt parent std bandwidth 10M default 821queue developers parent std bandwidth 75M 822queue employees parent std bandwidth 5M 823queue ipsec parent std bandwidth 10M 824 825pass out on ix0 proto esp set queue ipsec 826 827pass out on ix0 tagged ipsec-developers.example.com \e 828 set queue developers 829pass out on ix0 tagged ipsec-employees.example.com \e 830 set queue employees 831.Ed 832.Pp 833The following example assigns the tags in the 834.Nm 835configuration and also sets an alternative 836.Xr enc 4 837device: 838.Bd -literal -offset indent 839ikev2 esp from 10.1.1.0/24 to 10.1.2.0/24 peer 192.168.3.2 \e 840 tag "ipsec-$domain" tap "enc1" 841.Ed 842.Sh OUTGOING NETWORK ADDRESS TRANSLATION 843In some network topologies it is desirable to perform NAT on traffic leaving 844through the VPN tunnel. 845In order to achieve that, 846the 847.Ar src 848argument is used to negotiate the desired network ID with the peer 849and the 850.Ar srcnat 851parameter defines the true local subnet, 852so that a correct SA can be installed on the local side. 853.Pp 854For example, 855if the local subnet is 192.168.1.0/24 and all the traffic 856for a specific VPN peer should appear as coming from 10.10.10.1, 857the following configuration is used: 858.Bd -literal -offset indent 859ikev2 esp from 10.10.10.1 (192.168.1.0/24) to 192.168.2.0/24 \e 860 peer 10.10.20.1 861.Ed 862.Pp 863Naturally, 864a relevant NAT rule is required in 865.Xr pf.conf 5 . 866For the example above, 867this would be: 868.Bd -literal -offset indent 869match out on enc0 from 192.168.1.0/24 to 192.168.2.0/24 \e 870 nat-to 10.10.10.1 871.Ed 872.Pp 873From the peer's point of view, 874the local end of the VPN tunnel is declared to be 10.10.10.1 875and all the traffic arrives with that source address. 876.Sh CRYPTO TRANSFORMS 877The following authentication types are permitted with the 878.Ic auth 879keyword: 880.Bl -column "Authentication" "Key Length" "Truncated Length" "Default" -offset indent 881.It Em "Authentication" Ta Em "Key Length" Ta Em "Truncated Length" Ta Em "Default" 882.It Li hmac-md5 Ta "128 bits" Ta "96 bits" Ta "" 883.It Li hmac-sha1 Ta "160 bits" Ta "96 bits" Ta "x" 884.It Li hmac-sha2-256 Ta "256 bits" Ta "128 bits" Ta "x" 885.It Li hmac-sha2-384 Ta "384 bits" Ta "192 bits" Ta "x" 886.It Li hmac-sha2-512 Ta "512 bits" Ta "256 bits" Ta "x" 887.El 888.Pp 889The following pseudo-random function types are permitted with the 890.Ic prf 891keyword: 892.Bl -column "hmac-sha2-512" "Key Length" "Default" "[IKE only]" -offset indent 893.It Em "PRF" Ta Em "Key Length" Ta Em "Default" Ta "" 894.It Li hmac-md5 Ta "128 bits" Ta "" Ta "[IKE only]" 895.It Li hmac-sha1 Ta "160 bits" Ta "x" Ta "[IKE only]" 896.It Li hmac-sha2-256 Ta "256 bits" Ta "x" Ta "[IKE only]" 897.It Li hmac-sha2-384 Ta "384 bits" Ta "x" Ta "[IKE only]" 898.It Li hmac-sha2-512 Ta "512 bits" Ta "x" Ta "[IKE only]" 899.El 900.Pp 901The following cipher types are permitted with the 902.Ic enc 903keyword: 904.Bl -column "chacha20-poly1305" "Key Length" "Default" "[ESP only]" -offset indent 905.It Em "Cipher" Ta Em "Key Length" Ta Em "Default" Ta "" 906.It Li 3des Ta "168 bits" Ta "x" Ta "" 907.It Li aes-128 Ta "128 bits" Ta "x" Ta "" 908.It Li aes-192 Ta "192 bits" Ta "x" Ta "" 909.It Li aes-256 Ta "256 bits" Ta "x" Ta "" 910.It Li aes-128-ctr Ta "160 bits" Ta "" Ta "[ESP only]" 911.It Li aes-192-ctr Ta "224 bits" Ta "" Ta "[ESP only]" 912.It Li aes-256-ctr Ta "288 bits" Ta "" Ta "[ESP only]" 913.It Li aes-128-gcm Ta "160 bits" Ta "x" Ta "" 914.It Li aes-192-gcm Ta "224 bits" Ta "" Ta "[ESP only]" 915.It Li aes-256-gcm Ta "288 bits" Ta "x" Ta "" 916.It Li aes-128-gcm-12 Ta "160 bits" Ta "" Ta "[IKE only]" 917.It Li aes-256-gcm-12 Ta "288 bits" Ta "" Ta "[IKE only]" 918.It Li blowfish Ta "160 bits" Ta "" Ta "[ESP only]" 919.It Li cast Ta "128 bits" Ta "" Ta "[ESP only]" 920.It Li chacha20-poly1305 Ta "288 bits" Ta "" Ta "[ESP only]" 921.El 922.Pp 923The following cipher types provide only authentication, 924not encryption: 925.Bl -column "chacha20-poly1305" "Key Length" "Default" "[ESP only]" -offset indent 926.It Li aes-128-gmac Ta "160 bits" Ta "" Ta "[ESP only]" 927.It Li aes-192-gmac Ta "224 bits" Ta "" Ta "[ESP only]" 928.It Li aes-256-gmac Ta "288 bits" Ta "" Ta "[ESP only]" 929.It Li null Ta "" Ta "" Ta "[ESP only]" 930.El 931.Pp 932The Extended Sequence Numbers option can be enabled or disabled with the 933.Ic esn 934or 935.Ic noesn 936keywords: 937.Bl -column "noesn" "Default" "[ESP only]" -offset indent 938.It Em ESN Ta Em "Default" Ta Em "" 939.It Li esn Ta "x" Ta "[ESP only]" 940.It Li noesn Ta "x" Ta "[ESP only]" 941.El 942.Pp 943Transforms followed by 944.Bq IKE only 945can only be used with the 946.Ic ikesa 947keyword, transforms with 948.Bq ESP only 949can only be used with the 950.Ic childsa 951keyword. 952.Pp 9533DES requires 24 bytes to form its 168-bit key. 954This is because the most significant bit of each byte is used for parity. 955.Pp 956The keysize of AES-CTR is actually 128-bit. 957However as well as the key, a 32-bit nonce has to be supplied. 958Thus 160 bits of key material have to be supplied. 959The same applies to AES-GCM, AES-GMAC and Chacha20-Poly1305, 960however in the latter case the keysize is 256 bit. 961.Pp 962Using AES-GMAC or NULL with ESP will only provide authentication. 963This is useful in setups where AH cannot be used, e.g. when NAT is involved. 964.Pp 965The following group types are permitted with the 966.Ic group 967keyword: 968.Bl -column "brainpool224" "Group" "Size" "Curve25519" "Default" -offset indent 969.It Em Name Ta Em Group Ta Em Size Ta Em Type Ta Em Default 970.It Li modp768 Ta grp1 Ta 768 Ta "MODP" Ta "" Ta "[insecure]" 971.It Li modp1024 Ta grp2 Ta 1024 Ta "MODP" Ta "x" Ta "[weak]" 972.It Li modp1536 Ta grp5 Ta 1536 Ta "MODP" Ta "x" Ta "[weak]" 973.It Li modp2048 Ta grp14 Ta 2048 Ta "MODP" Ta "x" 974.It Li modp3072 Ta grp15 Ta 3072 Ta "MODP" Ta "x" 975.It Li modp4096 Ta grp16 Ta 4096 Ta "MODP" Ta "x" 976.It Li modp6144 Ta grp17 Ta 6144 Ta "MODP" Ta "" 977.It Li modp8192 Ta grp18 Ta 8192 Ta "MODP" Ta "" 978.It Li ecp256 Ta grp19 Ta 256 Ta "ECP" Ta "x" 979.It Li ecp384 Ta grp20 Ta 384 Ta "ECP" Ta "x" 980.It Li ecp521 Ta grp21 Ta 521 Ta "ECP" Ta "x" 981.It Li ecp192 Ta grp25 Ta 192 Ta "ECP" Ta "" 982.It Li ecp224 Ta grp26 Ta 224 Ta "ECP" Ta "" 983.It Li brainpool224 Ta grp27 Ta 224 Ta "ECP" Ta "" 984.It Li brainpool256 Ta grp28 Ta 256 Ta "ECP" Ta "" 985.It Li brainpool384 Ta grp29 Ta 384 Ta "ECP" Ta "" 986.It Li brainpool512 Ta grp30 Ta 512 Ta "ECP" Ta "" 987.It Li curve25519 Ta grp31 Ta 256 Ta "Curve25519" Ta "x" 988.El 989.Pp 990The currently supported group types are either 991MODP (exponentiation groups modulo a prime), 992ECP (elliptic curve groups modulo a prime), 993or Curve25519. 994Please note that MODP groups of less than 2048 bits are considered 995as weak or insecure (see RFC 8247 section 2.4) and only provided for 996backwards compatibility. 997.Sh FILES 998.Bl -tag -width /etc/examples/iked.conf -compact 999.It Pa /etc/iked.conf 1000.It Pa /etc/examples/iked.conf 1001.El 1002.Sh EXAMPLES 1003The first example is intended for a server with clients connecting to 1004.Xr iked 8 1005as an IPsec gateway, or IKEv2 responder, using mutual public key 1006authentication and additional challenge-based EAP-MSCHAPv2 password 1007authentication: 1008.Bd -literal -offset indent 1009user "test" "password123" 1010 1011ikev2 "win7" esp \e 1012 from dynamic to 172.16.2.0/24 \e 1013 peer 10.0.0.0/8 local 192.168.56.0/24 \e 1014 eap "mschap-v2" \e 1015 config address 172.16.2.1 \e 1016 tag "$name-$id" 1017.Ed 1018.Pp 1019The next example allows peers to authenticate using a pre-shared key 1020.Sq foobar : 1021.Bd -literal -offset indent 1022ikev2 "big test" \e 1023 esp proto tcp \e 1024 from 10.0.0.0/8 port 23 to 20.0.0.0/8 port 40 \e 1025 from 192.168.1.1 to 192.168.2.2 \e 1026 peer any local any \e 1027 ikesa \e 1028 enc 3des auth hmac-sha2-256 \e 1029 group ecp256 group modp1024 \e 1030 ikesa \e 1031 enc 3des auth hmac-sha1 \e 1032 group ecp256 group modp1024 \e 1033 childsa enc aes-128 auth hmac-sha2-256 \e 1034 childsa enc aes-128 auth hmac-sha1 \e 1035 srcid host.example.com \e 1036 dstid 192.168.0.254 \e 1037 psk "foobar" 1038.Ed 1039.Pp 1040The following example illustrates the last matching policy 1041evaluation for incoming connections on an IKEv2 gateway. 1042The peer 192.168.1.34 will always match the first policy because of the 1043.Ar quick 1044keyword; 1045connections from the peers 192.168.1.3 and 192.168.1.2 will be matched 1046by one of the last two policies; 1047any other connections from 192.168.1.0/24 will be matched by the 1048.Sq subnet 1049policy; 1050and any other connection will be matched by the 1051.Sq catch all 1052policy. 1053.Bd -literal -offset indent 1054ikev2 quick esp from 10.10.10.0/24 to 10.20.20.0/24 \e 1055 peer 192.168.1.34 1056ikev2 "catch all" esp from 10.0.1.0/24 to 10.0.2.0/24 \e 1057 peer any 1058ikev2 "subnet" esp from 10.0.3.0/24 to 10.0.4.0/24 \e 1059 peer 192.168.1.0/24 1060ikev2 esp from 10.0.5.0/30 to 10.0.5.4/30 peer 192.168.1.2 1061ikev2 esp from 10.0.5.8/30 to 10.0.5.12/30 peer 192.168.1.3 1062.Ed 1063.Pp 1064This example encrypts a 1065.Xr gre 4 1066tunnel from local machine A (2001:db8::aa:1) to peer D (2001:db8::dd:4) based on 1067FQDN-based public key authentication; 1068.Ar transport 1069mode avoids double encapsulation: 1070.Bd -literal -offset indent 1071ikev2 transport \e 1072 proto gre \e 1073 from 2001:db8::aa:1 to 2001:db8::dd:4 \e 1074 peer D.example.com 1075.Ed 1076.Sh SEE ALSO 1077.Xr enc 4 , 1078.Xr ipsec 4 , 1079.Xr ipsec.conf 5 , 1080.Xr pf.conf 5 , 1081.Xr ikectl 8 , 1082.Xr iked 8 1083.Sh HISTORY 1084The 1085.Nm 1086file format first appeared in 1087.Ox 4.8 . 1088.Sh AUTHORS 1089The 1090.Xr iked 8 1091program was written by 1092.An Reyk Floeter Aq Mt reyk@openbsd.org . 1093