19a4365d0SYoshinobu Inoue# Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. 29a4365d0SYoshinobu Inoue# All rights reserved. 39a4365d0SYoshinobu Inoue# 49a4365d0SYoshinobu Inoue# Redistribution and use in source and binary forms, with or without 59a4365d0SYoshinobu Inoue# modification, are permitted provided that the following conditions 69a4365d0SYoshinobu Inoue# are met: 79a4365d0SYoshinobu Inoue# 1. Redistributions of source code must retain the above copyright 89a4365d0SYoshinobu Inoue# notice, this list of conditions and the following disclaimer. 99a4365d0SYoshinobu Inoue# 2. Redistributions in binary form must reproduce the above copyright 109a4365d0SYoshinobu Inoue# notice, this list of conditions and the following disclaimer in the 119a4365d0SYoshinobu Inoue# documentation and/or other materials provided with the distribution. 129a4365d0SYoshinobu Inoue# 3. Neither the name of the project nor the names of its contributors 139a4365d0SYoshinobu Inoue# may be used to endorse or promote products derived from this software 149a4365d0SYoshinobu Inoue# without specific prior written permission. 159a4365d0SYoshinobu Inoue# 169a4365d0SYoshinobu Inoue# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 179a4365d0SYoshinobu Inoue# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 189a4365d0SYoshinobu Inoue# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 199a4365d0SYoshinobu Inoue# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 209a4365d0SYoshinobu Inoue# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 219a4365d0SYoshinobu Inoue# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 229a4365d0SYoshinobu Inoue# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 239a4365d0SYoshinobu Inoue# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 249a4365d0SYoshinobu Inoue# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 259a4365d0SYoshinobu Inoue# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 269a4365d0SYoshinobu Inoue# SUCH DAMAGE. 279a4365d0SYoshinobu Inoue# 289a4365d0SYoshinobu Inoue 299a4365d0SYoshinobu Inoue# There are sample scripts for IPsec configuration by manual keying. 309a4365d0SYoshinobu Inoue# A security association is uniquely identified by a triple consisting 319a4365d0SYoshinobu Inoue# of a Security Parameter Index (SPI), an IP Destination Address, and a 329a4365d0SYoshinobu Inoue# security protocol (AH or ESP) identifier. You must take care of these 339a4365d0SYoshinobu Inoue# parameters when you configure by manual keying. 349a4365d0SYoshinobu Inoue 359a4365d0SYoshinobu Inoue# ESP transport mode is recommended for TCP port number 110 between 36*16aabb76SJohn Baldwin# Host-A and Host-B. Encryption algorithm is aes-cbc whose key 37*16aabb76SJohn Baldwin# is "kamekamekamekamekamekamekamekame", and authentication algorithm is 38*16aabb76SJohn Baldwin# hmac-sha2-512 whose key is "this is the test key". 399a4365d0SYoshinobu Inoue# 409a4365d0SYoshinobu Inoue# ============ ESP ============ 419a4365d0SYoshinobu Inoue# | | 429a4365d0SYoshinobu Inoue# Host-A Host-B 439a4365d0SYoshinobu Inoue# fec0::10 -------------------- fec0::11 449a4365d0SYoshinobu Inoue# 459a4365d0SYoshinobu Inoue# At Host-A and Host-B, 469a4365d0SYoshinobu Inouespdadd fec0::10[any] fec0::11[110] tcp -P out ipsec 47cf43a054SHajimu UMEMOTO esp/transport//use ; 489a4365d0SYoshinobu Inouespdadd fec0::11[110] fec0::10[any] tcp -P in ipsec 49cf43a054SHajimu UMEMOTO esp/transport//use ; 509a4365d0SYoshinobu Inoueadd fec0::10 fec0::11 esp 0x10001 519a4365d0SYoshinobu Inoue -m transport 52*16aabb76SJohn Baldwin -E aes-cbc "kamekamekamekamekamekamekamekame" 53*16aabb76SJohn Baldwin -A hmac-sha2-512 "this is the test key" ; 549a4365d0SYoshinobu Inoueadd fec0::11 fec0::10 esp 0x10002 559a4365d0SYoshinobu Inoue -m transport 56*16aabb76SJohn Baldwin -E aes-cbc "kamekamekamekamekamekamekamekame" 57*16aabb76SJohn Baldwin -A hmac-sha2-512 "this is the test key" ; 589a4365d0SYoshinobu Inoue 599a4365d0SYoshinobu Inoue# "[any]" is wildcard of port number. Note that "[0]" is the number of 609a4365d0SYoshinobu Inoue# zero in port number. 619a4365d0SYoshinobu Inoue 62*16aabb76SJohn Baldwin# Security protocol is old AH tunnel mode, i.e. RFC1826, with hmac-sha2-256 639a4365d0SYoshinobu Inoue# whose key is "this is the test" as authentication algorithm. 649a4365d0SYoshinobu Inoue# That protocol takes place between Gateway-A and Gateway-B. 659a4365d0SYoshinobu Inoue# 669a4365d0SYoshinobu Inoue# ======= AH ======= 679a4365d0SYoshinobu Inoue# | | 689a4365d0SYoshinobu Inoue# Network-A Gateway-A Gateway-B Network-B 699a4365d0SYoshinobu Inoue# 10.0.1.0/24 ---- 172.16.0.1 ----- 172.16.0.2 ---- 10.0.2.0/24 709a4365d0SYoshinobu Inoue# 719a4365d0SYoshinobu Inoue# At Gateway-A: 729a4365d0SYoshinobu Inouespdadd 10.0.1.0/24 10.0.2.0/24 any -P out ipsec 739a4365d0SYoshinobu Inoue ah/tunnel/172.16.0.1-172.16.0.2/require ; 749a4365d0SYoshinobu Inouespdadd 10.0.2.0/24 10.0.1.0/24 any -P in ipsec 759a4365d0SYoshinobu Inoue ah/tunnel/172.16.0.2-172.16.0.1/require ; 769a4365d0SYoshinobu Inoueadd 172.16.0.1 172.16.0.2 ah-old 0x10003 779a4365d0SYoshinobu Inoue -m any 78*16aabb76SJohn Baldwin -A hmac-sha2-256 "this is the test" ; 799a4365d0SYoshinobu Inoueadd 172.16.0.2 172.16.0.1 ah-old 0x10004 809a4365d0SYoshinobu Inoue -m any 81*16aabb76SJohn Baldwin -A hmac-sha2-256 "this is the test" ; 829a4365d0SYoshinobu Inoue 839a4365d0SYoshinobu Inoue# If port number field is omitted such above then "[any]" is employed. 849a4365d0SYoshinobu Inoue# -m specifies the mode of SA to be used. "-m any" means wildcard of 859a4365d0SYoshinobu Inoue# mode of security protocol. You can use this SAs for both tunnel and 869a4365d0SYoshinobu Inoue# transport mode. 879a4365d0SYoshinobu Inoue 889a4365d0SYoshinobu Inoue# At Gateway-B. Attention to the selector and peer's IP address for tunnel. 899a4365d0SYoshinobu Inouespdadd 10.0.2.0/24 10.0.1.0/24 any -P out ipsec 909a4365d0SYoshinobu Inoue ah/tunnel/172.16.0.2-172.16.0.1/require ; 919a4365d0SYoshinobu Inouespdadd 10.0.1.0/24 10.0.2.0/24 any -P in ipsec 929a4365d0SYoshinobu Inoue ah/tunnel/172.16.0.1-172.16.0.2/require ; 939a4365d0SYoshinobu Inoueadd 172.16.0.1 172.16.0.2 ah-old 0x10003 949a4365d0SYoshinobu Inoue -m tunnel 95*16aabb76SJohn Baldwin -A hmac-sha2-256 "this is the test" ; 969a4365d0SYoshinobu Inoueadd 172.16.0.2 172.16.0.1 ah-old 0x10004 979a4365d0SYoshinobu Inoue -m tunnel 98*16aabb76SJohn Baldwin -A hmac-sha2-256 "this is the test" ; 999a4365d0SYoshinobu Inoue 1009a4365d0SYoshinobu Inoue# AH transport mode followed by ESP tunnel mode is required between 1019a4365d0SYoshinobu Inoue# Gateway-A and Gateway-B. 102*16aabb76SJohn Baldwin# Encryption algorithm is aes-cbc, and authentication algorithm for ESP 103*16aabb76SJohn Baldwin# is hmac-sha2-512. Authentication algorithm for AH is hmac-sha2-256. 1049a4365d0SYoshinobu Inoue# 1059a4365d0SYoshinobu Inoue# ========== AH ========= 1069a4365d0SYoshinobu Inoue# | ======= ESP ===== | 1079a4365d0SYoshinobu Inoue# | | | | 1089a4365d0SYoshinobu Inoue# Network-A Gateway-A Gateway-B Network-B 1099a4365d0SYoshinobu Inoue# fec0:0:0:1::/64 --- fec0:0:0:1::1 ---- fec0:0:0:2::1 --- fec0:0:0:2::/64 1109a4365d0SYoshinobu Inoue# 1119a4365d0SYoshinobu Inoue# At Gateway-A: 1129a4365d0SYoshinobu Inouespdadd fec0:0:0:1::/64 fec0:0:0:2::/64 any -P out ipsec 1139a4365d0SYoshinobu Inoue esp/tunnel/fec0:0:0:1::1-fec0:0:0:2::1/require 114cf43a054SHajimu UMEMOTO ah/transport//require ; 1159a4365d0SYoshinobu Inouespdadd fec0:0:0:2::/64 fec0:0:0:1::/64 any -P in ipsec 1169a4365d0SYoshinobu Inoue esp/tunnel/fec0:0:0:2::1-fec0:0:0:1::1/require 117cf43a054SHajimu UMEMOTO ah/transport//require ; 1189a4365d0SYoshinobu Inoueadd fec0:0:0:1::1 fec0:0:0:2::1 esp 0x10001 1199a4365d0SYoshinobu Inoue -m tunnel 120*16aabb76SJohn Baldwin -E aes-cbc "kamekame12341234kamekame12341234" 121*16aabb76SJohn Baldwin -A hmac-sha2-512 "this is the test key" ; 1229a4365d0SYoshinobu Inoueadd fec0:0:0:1::1 fec0:0:0:2::1 ah 0x10001 1239a4365d0SYoshinobu Inoue -m transport 124*16aabb76SJohn Baldwin -A hmac-sha2-256 "this is the test" ; 1259a4365d0SYoshinobu Inoueadd fec0:0:0:2::1 fec0:0:0:1::1 esp 0x10001 1269a4365d0SYoshinobu Inoue -m tunnel 127*16aabb76SJohn Baldwin -E aes-cbc "kamekame12341234kamekame12341234" 128*16aabb76SJohn Baldwin -A hmac-sha2-512 "this is the test key" ; 1299a4365d0SYoshinobu Inoueadd fec0:0:0:2::1 fec0:0:0:1::1 ah 0x10001 1309a4365d0SYoshinobu Inoue -m transport 131*16aabb76SJohn Baldwin -A hmac-sha2-256 "this is the test" ; 1329a4365d0SYoshinobu Inoue 1339a4365d0SYoshinobu Inoue# ESP tunnel mode is required between Host-A and Gateway-A. 134*16aabb76SJohn Baldwin# Encryption algorithm is aes-cbc, and authentication algorithm 135*16aabb76SJohn Baldwin# for ESP is hmac-sha2-256. 1369a4365d0SYoshinobu Inoue# ESP transport mode is recommended between Host-A and Host-B. 137*16aabb76SJohn Baldwin# Encryption algorithm is aes-ctr, and authentication algorithm 138*16aabb76SJohn Baldwin# for ESP is hmac-sha2-512. 1399a4365d0SYoshinobu Inoue# 1409a4365d0SYoshinobu Inoue# ================== ESP ================= 1419a4365d0SYoshinobu Inoue# | ======= ESP ======= | 1429a4365d0SYoshinobu Inoue# | | | | 1439a4365d0SYoshinobu Inoue# Host-A Gateway-A Host-B 1449a4365d0SYoshinobu Inoue# fec0:0:0:1::1 ---- fec0:0:0:2::1 ---- fec0:0:0:2::2 1459a4365d0SYoshinobu Inoue# 1469a4365d0SYoshinobu Inoue# At Host-A: 1479a4365d0SYoshinobu Inouespdadd fec0:0:0:1::1[any] fec0:0:0:2::2[80] tcp -P out ipsec 148cf43a054SHajimu UMEMOTO esp/transport//use 1499a4365d0SYoshinobu Inoue esp/tunnel/fec0:0:0:1::1-fec0:0:0:2::1/require ; 1509a4365d0SYoshinobu Inouespdadd fec0:0:0:2::1[80] fec0:0:0:1::1[any] tcp -P in ipsec 151cf43a054SHajimu UMEMOTO esp/transport//use 1529a4365d0SYoshinobu Inoue esp/tunnel/fec0:0:0:2::1-fec0:0:0:1::1/require ; 1539a4365d0SYoshinobu Inoueadd fec0:0:0:1::1 fec0:0:0:2::2 esp 0x10001 1549a4365d0SYoshinobu Inoue -m transport 155*16aabb76SJohn Baldwin -E aes-cbc "kamekame12341234kamekame12341234" 156*16aabb76SJohn Baldwin -A hmac-sha2-256 "this is the test key" ; 1579a4365d0SYoshinobu Inoueadd fec0:0:0:1::1 fec0:0:0:2::1 esp 0x10002 158*16aabb76SJohn Baldwin -E aes-ctr "kamekame12341234kamekame12341234f00f" 159*16aabb76SJohn Baldwin -A hmac-sha2-512 "this is the test" ; 1609a4365d0SYoshinobu Inoueadd fec0:0:0:2::2 fec0:0:0:1::1 esp 0x10003 1619a4365d0SYoshinobu Inoue -m transport 162*16aabb76SJohn Baldwin -E aes-cbc "kamekame12341234kamekame12341234" 163*16aabb76SJohn Baldwin -A hmac-sha2-256 "this is the test key" ; 1649a4365d0SYoshinobu Inoueadd fec0:0:0:2::1 fec0:0:0:1::1 esp 0x10004 165*16aabb76SJohn Baldwin -E aes-ctr "kamekame12341234kamekame12341234f00f" 166*16aabb76SJohn Baldwin -A hmac-sha2-512 "this is the test" ; 1679a4365d0SYoshinobu Inoue 168cf43a054SHajimu UMEMOTO# By "get" command, you can get a entry of either SP or SA. 1699a4365d0SYoshinobu Inoueget fec0:0:0:1::1 fec0:0:0:2::2 ah 0x10004 ; 1709a4365d0SYoshinobu Inoue 171cf43a054SHajimu UMEMOTO# Also delete command, you can delete a entry of either SP or SA. 1723c62e87aSJun-ichiro itojun Haginospddelete fec0:0:0:1::/64 fec0:0:0:2::/64 any -P out; 1739a4365d0SYoshinobu Inouedelete fec0:0:0:1::1 fec0:0:0:2::2 ah 0x10004 ; 1749a4365d0SYoshinobu Inoue 1759a4365d0SYoshinobu Inoue# By dump command, you can dump all entry of either SP or SA. 1769a4365d0SYoshinobu Inouedump ; 1779a4365d0SYoshinobu Inouespddump ; 1789a4365d0SYoshinobu Inouedump esp ; 1799a4365d0SYoshinobu Inoueflush esp ; 1809a4365d0SYoshinobu Inoue 1819a4365d0SYoshinobu Inoue# By flush command, you can flush all entry of either SP or SA. 1829a4365d0SYoshinobu Inoueflush ; 1839a4365d0SYoshinobu Inouespdflush ; 1849a4365d0SYoshinobu Inoue 1859a4365d0SYoshinobu Inoue# "flush" and "dump" commands can specify a security protocol. 1869a4365d0SYoshinobu Inouedump esp ; 1879a4365d0SYoshinobu Inoueflush ah ; 1889a4365d0SYoshinobu Inoue 1899a4365d0SYoshinobu Inoue# XXX 190cf43a054SHajimu UMEMOTOadd ::1 ::1 esp 10001 -m transport -E null ; 191cf43a054SHajimu UMEMOTOadd ::1 ::1 esp 10004 -m transport -E null -A null ; 192cf43a054SHajimu UMEMOTOadd ::1 ::1 esp 10006 -m tunnel -E null -A hmac-sha1 "12341234123412341234" ; 193cf43a054SHajimu UMEMOTOadd ::1 ::1 esp 10015 -m transport -f zero-pad -E null ; 194cf43a054SHajimu UMEMOTOadd ::1 ::1 esp 10016 -m tunnel -f random-pad -r 8 -lh 100 -ls 80 -E null ; 195cf43a054SHajimu UMEMOTOadd ::1 ::1 esp 10017 -m transport -f seq-pad -f nocyclic-seq -E null ; 196cf43a054SHajimu UMEMOTOadd ::1 ::1 esp 10018 -m transport -E null ; 1979a4365d0SYoshinobu Inoue#add ::1 ::1 ah 20000 -m transport -A null ; 1989a4365d0SYoshinobu Inoueadd ::1 ::1 ah 20002 -m tunnel -A hmac-sha1 "12341234123412341234"; 1999a4365d0SYoshinobu Inoue#add ::1 ::1 ipcomp 30000 -C oui ; 2009a4365d0SYoshinobu Inoueadd ::1 ::1 ipcomp 30001 -C deflate ; 2019a4365d0SYoshinobu Inoue#add ::1 ::1 ipcomp 30002 -C lzs ; 2029a4365d0SYoshinobu Inoue 2039a4365d0SYoshinobu Inoue# enjoy. 204