1.\" $NetBSD: setkey.8,v 1.37 2019/07/23 14:28:24 wiz Exp $ 2.\" 3.\" Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the project nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.Dd July 23, 2019 31.Dt SETKEY 8 32.Os 33.\" 34.Sh NAME 35.Nm setkey 36.Nd manually manipulate the IPsec SA/SP database 37.\" 38.Sh SYNOPSIS 39.Nm setkey 40.Op Fl knrv 41.Ar file ... 42.Nm setkey 43.Op Fl knrv 44.Fl c 45.Nm setkey 46.Op Fl krv 47.Fl f Ar filename 48.Nm setkey 49.Op Fl aklPrv 50.Fl D 51.Nm setkey 52.Op Fl Pvp 53.Fl F 54.Nm setkey 55.Op Fl H 56.Fl x 57.Nm setkey 58.Op Fl ?V 59.\" 60.Sh DESCRIPTION 61.Nm 62adds, updates, dumps, or flushes 63Security Association Database (SAD) entries 64as well as Security Policy Database (SPD) entries in the kernel. 65.Pp 66.Nm 67takes a series of operations from standard input 68.Po 69if invoked with 70.Fl c 71.Pc 72or the file named 73.Ar filename 74.Po 75if invoked with 76.Fl f Ar filename 77.Pc . 78.Bl -tag -width Ds 79.It (no flag) 80Dump the SAD entries or SPD entries contained in the specified 81.Ar file . 82.It Fl ? 83Print short help. 84.It Fl a 85.Nm 86usually does not display dead SAD entries with 87.Fl D . 88If 89.Fl a 90is also specified, the dead SAD entries will be displayed as well. 91A dead SAD entry is one that has expired but remains in the 92system because it is referenced by some SPD entries. 93.It Fl D 94Dump the SAD entries. 95If 96.Fl P 97is also specified, the SPD entries are dumped. 98If 99.Fl p 100is specified, the ports are displayed. 101.It Fl F 102Flush the SAD entries. 103If 104.Fl P 105is also specified, the SPD entries are flushed. 106.It Fl H 107Add hexadecimal dump in 108.Fl x 109mode. 110.It Fl h 111On 112.Nx , 113synonym for 114.Fl H . 115On other systems, synonym for 116.Fl ? . 117.It Fl k 118Use semantics used in kernel. 119Available only in Linux. 120See also 121.Fl r . 122.It Fl l 123Loop forever with short output on 124.Fl D . 125.It Fl n 126No action. 127The program will check validity of the input, but no changes to 128the SPD will be made. 129.It Fl r 130Use semantics described in IPsec RFCs. 131This mode is default. 132For details see section 133.Sx RFC vs Linux kernel semantics . 134Available only in Linux. 135See also 136.Fl k . 137.It Fl x 138Loop forever and dump all the messages transmitted to the 139.Dv PF_KEY 140socket. 141.Fl xx 142prints the unformatted timestamps. 143.It Fl V 144Print version string. 145.It Fl v 146Be verbose. 147The program will dump messages exchanged on the 148.Dv PF_KEY 149socket, including messages sent from other processes to the kernel. 150.El 151.Ss Configuration syntax 152With 153.Fl c 154or 155.Fl f 156on the command line, 157.Nm 158accepts the following configuration syntax. 159Lines starting with hash signs 160.Pq Sq # 161are treated as comment lines. 162.Bl -tag -width Ds 163.It Cm add Oo Fl 46n Oc Ar src Ar dst Ar protocol Ar spi \ 164Oo Ar extensions Oc Ar algorithm ... ; 165Add an SAD entry. 166.Cm add 167can fail for multiple reasons, including when the key length does 168not match the specified algorithm. 169.\" 170.It Cm getspi Oo Fl 46n Oc Ar src Ar dst Ar protocol Ar spi \ 171Oo Ar extensions Oc ; 172Add a larval SAD entry. 173If 174.Ar spi 175is not zero, tell the kernel use the SPI as-is. 176Otherwise, the kernel picks a random SPI. 177.\" 178.It Cm update Oo Fl 46n Oc Ar src Ar dst Ar protocol Ar spi \ 179Oo Ar extensions Oc Ar algorithm ... ; 180Update an existing SAD entry. 181It must be used together with 182.Cm add 183or 184.Cm getspi 185in a series of operations because the API requires that a process 186updating an SAD entry is the same as one created the SAD entry. 187.\" 188.It Cm get Oo Fl 46n Oc Ar src Ar dst Ar protocol Ar spi ; 189Show an SAD entry. 190.\" 191.It Cm delete Oo Fl 46n Oc Ar src Ar dst Ar protocol Ar spi ; 192Remove an SAD entry. 193.\" 194.It Cm deleteall Oo Fl 46n Oc Ar src Ar dst Ar protocol ; 195Remove all SAD entries that match the specification. 196.\" 197.It Cm flush Oo Ar protocol Oc ; 198Clear all SAD entries matched by the options. 199.Fl F 200on the command line achieves the same functionality. 201.\" 202.It Cm dump Oo Ar protocol Oc ; 203Dumps all SAD entries matched by the options. 204.Fl D 205on the command line achieves the same functionality. 206.\" 207.It Cm spdadd Oo Fl 46n Oc Ar src_range Ar dst_range Ar upperspec \ 208Ar label Ar policy ; 209Add an SPD entry. 210.\" 211.It Cm spdadd tagged Ar tag Ar policy ; 212Add an SPD entry based on a PF tag. 213.Ar tag 214must be a string surrounded by double quotes. 215.\" 216.It Cm spdupdate Oo Fl 46n Oc Ar src_range Ar dst_range Ar upperspec \ 217Ar label Ar policy ; 218Updates an SPD entry. 219.\" 220.It Cm spdupdate tagged Ar tag Ar policy ; 221Update an SPD entry based on a PF tag. 222.Ar tag 223must be a string surrounded by double quotes. 224.\" 225.It Cm spddelete Oo Fl 46n Oc Ar src_range Ar dst_range Ar upperspec \ 226Fl P Ar direction ; 227Delete an SPD entry. 228.\" 229.It Cm spdflush ; 230Clear all SPD entries. 231.Fl FP 232on the command line achieves the same functionality. 233.\" 234.It Cm spddump ; 235Dumps all SPD entries. 236.Fl DP 237on the command line achieves the same functionality. 238.El 239.\" 240.Pp 241Meta-arguments are as follows: 242.Pp 243.Bl -tag -compact -width Ds 244.It Ar src 245.It Ar dst 246Source/destination of the secure communication is specified as 247an IPv4/v6 address, and an optional port number between square 248brackets. 249.Nm 250can resolve a FQDN into numeric addresses. 251If the FQDN resolves into multiple addresses, 252.Nm 253will install multiple SAD/SPD entries into the kernel 254by trying all possible combinations. 255.Fl 4 , 256.Fl 6 , 257and 258.Fl n 259restrict the address resolution of FQDN in certain ways. 260.Fl 4 261and 262.Fl 6 263restrict results into IPv4/v6 addresses only, respectively. 264.Fl n 265avoids FQDN resolution and requires addresses to be numeric addresses. 266.\" 267.Pp 268.It Ar protocol 269.Ar protocol 270is one of following: 271.Bl -tag -width Fl -compact 272.It Cm esp 273ESP based on rfc2406 274.It Cm esp-old 275ESP based on rfc1827 276.It Cm esp-udp 277UDP encapsulated ESP for NAT traversal (rfc3948) 278.It Cm ah 279AH based on rfc2402 280.It Cm ah-old 281AH based on rfc1826 282.It Cm ipcomp 283IPComp 284.It Cm tcp 285TCP-MD5 based on rfc2385 286.El 287.\" 288.Pp 289.It Ar spi 290Security Parameter Index 291.Pq SPI 292for the SAD and the SPD. 293.Ar spi 294must be a decimal number, or a hexadecimal number with a 295.Dq Li 0x 296prefix. 297SPI values between 0 and 255 are reserved for future use by IANA 298and cannot be used. 299TCP-MD5 associations must use 0x1000 and therefore only have per-host 300granularity at this time. 301.\" 302.Pp 303.It Ar extensions 304take some of the following: 305.Bl -tag -width Fl -compact 306.\" 307.It Fl m Ar mode 308Specify a security protocol mode for use. 309.Ar mode 310is one of following: 311.Cm transport , tunnel , 312or 313.Cm any . 314The default value is 315.Cm any . 316.\" 317.It Fl r Ar size 318Specify window size of bytes for replay prevention. 319.Ar size 320must be decimal number in 32-bit word. 321If 322.Ar size 323is zero or not specified, replay checks don't take place. 324.\" 325.It Fl u Ar id 326Specify the identifier of the policy entry in the SPD. 327See 328.Ar policy . 329.\" 330.It Fl f Ar pad_option 331defines the content of the ESP padding. 332.Ar pad_option 333is one of following: 334.Bl -tag -width random-pad -compact 335.It Cm zero-pad 336All the paddings are zero. 337.It Cm random-pad 338A series of randomized values are used. 339.It Cm seq-pad 340A series of sequential increasing numbers started from 1 are used. 341.El 342.\" 343.It Fl f Li nocyclic-seq 344Don't allow cyclic sequence numbers. 345.\" 346.It Fl lh Ar time 347.It Fl ls Ar time 348Specify hard/soft life time duration of the SA measured in seconds. 349.\" 350.It Fl bh Ar bytes 351.It Fl bs Ar bytes 352Specify hard/soft life time duration of the SA measured in bytes transported. 353.\" 354.It Fl esp_frag Ar bytes 355Specify esp fragment size for NAT-T (only valid for NAT-T SAs). 356.\" 357.It Fl ctx Ar doi Ar algorithm Ar context-name 358Specify an access control label. 359The access control label is interpreted by the LSM (e.g., SELinux). 360Ultimately, it enables MAC on network communications. 361.Bl -tag -width Fl -compact 362.It Ar doi 363The domain of interpretation, which is used by the 364IKE daemon to identify the domain in which negotiation takes place. 365.It Ar algorithm 366Indicates the LSM for which the label is generated (e.g., SELinux). 367.It Ar context-name 368The string representation of the label that is interpreted by the LSM. 369.El 370.El 371.\" 372.Pp 373.It Ar algorithm 374.Bl -tag -width Fl -compact 375.It Fl E Ar ealgo Ar key 376Specify an encryption algorithm 377.Ar ealgo 378for ESP. 379.It Fl E Ar ealgo Ar key Fl A Ar aalgo Ar key 380Specify an encryption algorithm 381.Ar ealgo , 382as well as a payload authentication algorithm 383.Ar aalgo , 384for ESP. 385.It Fl A Ar aalgo Ar key 386Specify an authentication algorithm for AH. 387.It Fl C Ar calgo Op Fl R 388Specify a compression algorithm for IPComp. 389If 390.Fl R 391is specified, the 392.Ar spi 393field value will be used as the IPComp CPI 394.Pq compression parameter index 395on wire as-is. 396If 397.Fl R 398is not specified, 399the kernel will use well-known CPI on wire, and 400.Ar spi 401field will be used only as an index for kernel internal usage. 402.El 403.Pp 404.Ar key 405must be a double-quoted character string, or a series of hexadecimal 406digits preceded by 407.Dq Li 0x . 408.Pp 409Possible values for 410.Ar ealgo , 411.Ar aalgo , 412and 413.Ar calgo 414are specified in the 415.Sx Algorithms 416sections. 417.\" 418.Pp 419.It Ar src_range 420.It Ar dst_range 421These select the communications that should be secured by IPsec. 422They can be an IPv4/v6 address or an IPv4/v6 address range, and 423may be accompanied by a TCP/UDP port specification. 424This takes the following form: 425.Bd -literal -offset 4n 426.Ar address 427.Ar address/prefixlen 428.Ar address[port] 429.Ar address/prefixlen[port] 430.Ed 431.Pp 432.Ar prefixlen 433and 434.Ar port 435must be decimal numbers. 436The square brackets around 437.Ar port 438are really necessary, 439they are not man page meta-characters. 440For FQDN resolution, the rules applicable to 441.Ar src 442and 443.Ar dst 444apply here as well. 445.\" 446.Pp 447.It Ar upperspec 448Upper-layer protocol to be used. 449You can use one of the words in 450.Pa /etc/protocols 451as 452.Ar upperspec , 453or 454.Cm icmp6 , 455.Cm ip4 , 456.Cm gre , 457or 458.Cm any . 459.Cm any 460stands for 461.Dq any protocol . 462You can also use the protocol number. 463Additional specification can be placed after the protocol name for 464some protocols. 465You can specify a type and/or a code of ICMP or ICMPv6. 466The type is separated from a code by single comma and the code must 467always be specified. 468GRE key can be specified in dotted-quad format or as plain number. 469When a zero is specified, the kernel deals with it as a wildcard. 470Note that the kernel can not distinguish a wildcard from an ICPMv6 471type of zero. 472.Pp 473For example, the following means that the policy doesn't require IPsec 474for any inbound Neighbor Solicitation. 475.Dl spdadd ::/0 ::/0 icmp6 135,0 -P in none ; 476.Pp 477A second example of requiring transport mode encryption of specific 478GRE tunnel: 479.Dl spdadd 0.0.0.0 0.0.0.0 gre 1234 ipsec esp/transport//require ; 480.Pp 481.Em Note : 482.Ar upperspec 483does not work against forwarding case at this moment, 484as it requires extra reassembly at the forwarding node 485.Pq not implemented at this moment . 486There are many protocols in 487.Pa /etc/protocols , 488but all protocols except of TCP, UDP, GRE, and ICMP may not be suitable 489to use with IPsec. 490You have to consider carefully what to use. 491.\" 492.Pp 493.It Ar label 494.Ar label 495is the access control label for the policy. 496This label is interpreted by the LSM (e.g., SELinux). 497Ultimately, it enables MAC on network communications. 498When a policy contains an access control label, SAs 499negotiated with this policy will contain the label. 500Its format: 501.Bl -tag -width Fl -compact 502.\" 503.It Fl ctx Ar doi Ar algorithm Ar context-name 504.Bl -tag -width Fl -compact 505.It Ar doi 506The domain of interpretation, which is used by the 507IKE daemon to identify the domain in which negotiation takes place. 508.It Ar algorithm 509Indicates the LSM for which the label is generated (e.g., SELinux). 510.It Ar context-name 511The string representation of the label that is interpreted by the LSM. 512.El 513.El 514.\" 515.Pp 516.It Ar policy 517.Ar policy 518is in one of the following three formats: 519.Bl -item -compact 520.It 521.Fl P Ar direction [priority specification] Cm discard 522.It 523.Fl P Ar direction [priority specification] Cm none 524.It 525.Fl P Ar direction [priority specification] Cm ipsec 526.Ar protocol/mode/src-dst/level Op ... 527.El 528.Pp 529You must specify the direction of its policy as 530.Ar direction . 531Either 532.Cm out , 533.Cm in , 534or 535.Cm fwd 536can be used. 537.Pp 538.Ar priority specification 539is used to control the placement of the policy within the SPD. 540Policy position is determined by 541a signed integer where higher priorities indicate the policy is placed 542closer to the beginning of the list and lower priorities indicate the 543policy is placed closer to the end of the list. 544Policies with equal priorities are added at the end of groups 545of such policies. 546.Pp 547Priority can only 548be specified when setkey has been compiled against kernel headers that 549support policy priorities (Linux \*[Gt]= 2.6.6). 550If the kernel does not support priorities, a warning message will 551be printed the first time a priority specification is used. 552Policy priority takes one of the following formats: 553.Bl -tag -width "discard" 554.It Ar {priority,prio} offset 555.Ar offset 556is an integer in the range from \-2147483647 to 214783648. 557.It Ar {priority,prio} base {+,\-} offset 558.Ar base 559is either 560.Cm low 561(\-1073741824), 562.Cm def 563(0), or 564.Cm high 565(1073741824) 566.Pp 567.Ar offset 568is an unsigned integer. 569It can be up to 1073741824 for 570positive offsets, and up to 1073741823 for negative offsets. 571.El 572.Pp 573.Cm discard 574means the packet matching indexes will be discarded. 575.Cm none 576means that IPsec operation will not take place onto the packet. 577.Cm ipsec 578means that IPsec operation will take place onto the packet. 579.Pp 580The 581.Ar protocol/mode/src-dst/level 582part specifies the rule how to process the packet. 583Either 584.Cm ah , 585.Cm esp , 586or 587.Cm ipcomp 588must be used as 589.Ar protocol . 590.Ar mode 591is either 592.Cm transport 593or 594.Cm tunnel . 595If 596.Ar mode 597is 598.Cm tunnel , 599you must specify the end-point addresses of the SA as 600.Ar src 601and 602.Ar dst 603with 604.Sq - 605between these addresses, which is used to specify the SA to use. 606If 607.Ar mode 608is 609.Cm transport , 610both 611.Ar src 612and 613.Ar dst 614can be omitted. 615.Ar level 616is to be one of the following: 617.Cm default , use , require , 618or 619.Cm unique . 620If the SA is not available in every level, the kernel will 621ask the key exchange daemon to establish a suitable SA. 622.Cm default 623means the kernel consults the system wide default for the protocol 624you specified, e.g. the 625.Cm esp_trans_deflev 626sysctl variable, when the kernel processes the packet. 627.Cm use 628means that the kernel uses an SA if it's available, 629otherwise the kernel keeps normal operation. 630.Cm require 631means SA is required whenever the kernel sends a packet matched 632with the policy. 633.Cm unique 634is the same as 635.Cm require ; 636in addition, it allows the policy to match the unique out-bound SA. 637You just specify the policy level 638.Cm unique , 639.Xr racoon 8 640will configure the SA for the policy. 641If you configure the SA by manual keying for that policy, 642you can put a decimal number as the policy identifier after 643.Cm unique 644separated by a colon 645.Sq \&: 646like: 647.Cm unique : Ns Ar number 648in order to bind this policy to the SA. 649.Ar number 650must be between 1 and 32767. 651It corresponds to 652.Ar extensions Fl u 653of the manual SA configuration. 654When you want to use SA bundle, you can define multiple rules. 655For example, if an IP header was followed by an AH header followed 656by an ESP header followed by an upper layer protocol header, the 657rule would be: 658.Dl esp/transport//require ah/transport//require ; 659The rule order is very important. 660.Pp 661When NAT-T is enabled in the kernel, policy matching for ESP over 662UDP packets may be done on endpoint addresses and port 663(this depends on the system. 664System that do not perform the port check cannot support 665multiple endpoints behind the same NAT). 666When using ESP over UDP, you can specify port numbers in the endpoint 667addresses to get the correct matching. 668Here is an example: 669.Bd -literal -offset 4n 670spdadd 10.0.11.0/24[any] 10.0.11.33/32[any] any \-P out ipsec 671 esp/tunnel/192.168.0.1[4500]-192.168.1.2[30000]/require ; 672 673.Ed 674These ports must be left unspecified (which defaults to 0) for 675anything other than ESP over UDP. 676They can be displayed in SPD dump using 677.Nm 678.Fl DPp . 679.Pp 680Note that 681.Cm discard 682and 683.Cm none 684are not in the syntax described in 685.Xr ipsec_set_policy 3 . 686There are a few differences in the syntax. 687See 688.Xr ipsec_set_policy 3 689for detail. 690.El 691.\" 692.Ss Algorithms 693The following list shows the supported algorithms. 694.Sy protocol 695and 696.Sy algorithm 697are almost orthogonal. 698These authentication algorithms can be used as 699.Ar aalgo 700in 701.Fl A Ar aalgo 702of the 703.Ar protocol 704parameter: 705.Bd -literal -offset indent 706algorithm keylen (bits) 707hmac-md5 128 ah: rfc2403 708 128 ah-old: rfc2085 709hmac-sha1 160 ah: rfc2404 710 160 ah-old: 128bit ICV (no document) 711keyed-md5 128 ah: 96bit ICV (no document) 712 128 ah-old: rfc1828 713keyed-sha1 160 ah: 96bit ICV (no document) 714 160 ah-old: 128bit ICV (no document) 715null 0 to 2048 for debugging 716hmac-sha256 256 ah: 128bit ICV (RFC4868) 717 256 ah-old: 128bit ICV (no document) 718hmac-sha384 384 ah: 192bit ICV (RFC4868) 719 384 ah-old: 128bit ICV (no document) 720hmac-sha512 512 ah: 256bit ICV (RFC4868) 721 512 ah-old: 128bit ICV (no document) 722hmac-ripemd160 160 ah: 96bit ICV (RFC2857) 723 ah-old: 128bit ICV (no document) 724aes-xcbc-mac 128 ah: 96bit ICV (RFC3566) 725 128 ah-old: 128bit ICV (no document) 726tcp-md5 8 to 640 tcp: rfc2385 727.Ed 728.Pp 729These encryption algorithms can be used as 730.Ar ealgo 731in 732.Fl E Ar ealgo 733of the 734.Ar protocol 735parameter: 736.Bd -literal -offset indent 737algorithm keylen (bits) 738des-cbc 64 esp-old: rfc1829, esp: rfc2405 7393des-cbc 192 rfc2451 740null 0 to 2048 rfc2410 741blowfish-cbc 40 to 448 rfc2451 742cast128-cbc 40 to 128 rfc2451 743des-deriv 64 ipsec-ciph-des-derived-01 7443des-deriv 192 no document 745rijndael-cbc 128/192/256 rfc3602 746twofish-cbc 0 to 256 draft-ietf-ipsec-ciph-aes-cbc-01 747aes-ctr 160/224/288 rfc3686 748camellia-cbc 128/192/256 rfc4312 749aes-gcm-16 160/224/288 rfc4106 750aes-gmac 160/224/288 rfc4543 751.Ed 752.Pp 753Note that the first 128/192/256 bits of a key for 754.Cm aes-ctr , 755.Cm aes-gcm-16 756or 757.Cm aes-gmac 758will be used as AES key, and the remaining 32 bits will be used as nonce. 759Also note that 760.Cm aes-gmac 761does not encrypt the payload, it only provides authentication. 762.Pp 763These compression algorithms can be used as 764.Ar calgo 765in 766.Fl C Ar calgo 767of the 768.Ar protocol 769parameter: 770.Bd -literal -offset indent 771algorithm 772deflate rfc2394 773.Ed 774.\" 775.Ss RFC vs Linux kernel semantics 776The Linux kernel uses the 777.Cm fwd 778policy instead of the 779.Cm in 780policy for packets what are forwarded through that particular box. 781.Pp 782In 783.Ar kernel 784mode, 785.Nm 786manages and shows policies and SAs exactly as they are stored in the kernel. 787.Pp 788In 789.Ar RFC 790mode, 791.Nm 792.Bl -item 793.It 794creates 795.Cm fwd 796policies for every 797.Cm in 798policy inserted 799.It 800(not implemented yet) filters out all 801.Cm fwd 802policies 803.El 804.Sh EXIT STATUS 805.Ex -std setkey 806.\" 807.Sh EXAMPLES 808.Bd -literal -offset 4n 809add 3ffe:501:4819::1 3ffe:501:481d::1 esp 123457 810 \-E des-cbc 0x3ffe05014819ffff ; 811 812add \-6 myhost.example.com yourhost.example.com ah 123456 813 \-A hmac-sha1 "AH SA configuration!" ; 814 815add 10.0.11.41 10.0.11.33 esp 0x10001 816 \-E des-cbc 0x3ffe05014819ffff 817 \-A hmac-md5 "authentication!!" ; 818 819get 3ffe:501:4819::1 3ffe:501:481d::1 ah 123456 ; 820 821flush ; 822 823dump esp ; 824 825spdadd 10.0.11.41/32[21] 10.0.11.33/32[any] any 826 \-P out ipsec esp/tunnel/192.168.0.1-192.168.1.2/require ; 827 828add 10.1.10.34 10.1.10.36 tcp 0x1000 \-A tcp-md5 "TCP-MD5 BGP secret" ; 829 830add 10.0.11.41 10.0.11.33 esp 0x10001 831 \-ctx 1 1 "system_u:system_r:unconfined_t:SystemLow-SystemHigh" 832 \-E des-cbc 0x3ffe05014819ffff; 833 834spdadd 10.0.11.41 10.0.11.33 any 835 \-ctx 1 1 "system_u:system_r:unconfined_t:SystemLow-SystemHigh" 836 \-P out ipsec esp/transport//require ; 837.Ed 838.\" 839.Sh SEE ALSO 840.Xr ipsec_set_policy 3 , 841.Xr racoon 8 , 842.Xr sysctl 8 843.Rs 844.%T "Changed manual key configuration for IPsec" 845.%U "http://www.kame.net/newsletter/19991007/" 846.%D "October 1999" 847.Re 848.\" 849.Sh HISTORY 850The 851.Nm 852command first appeared in the WIDE Hydrangea IPv6 protocol stack 853kit. 854The command was completely re-designed in June 1998. 855.\" 856.Sh BUGS 857.Nm 858should report and handle syntax errors better. 859.Pp 860For IPsec gateway configuration, 861.Ar src_range 862and 863.Ar dst_range 864with TCP/UDP port numbers does not work, as the gateway does not 865reassemble packets 866.Pq it cannot inspect upper-layer headers . 867