Strongswan zu strongswan ikev2 site to site: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
(Die Seite wurde neu angelegt: „=Strongswan= ==alice und tiazel== */etc/ipsec.conf <pre> conn s2s authby=secret keyexchange=ikev2 left=192.168.244.93 leftid=@alice le…“)
 
Zeile 1: Zeile 1:
=Strongswan=
+
 
==alice und tiazel==
+
 
*/etc/ipsec.conf
+
=Config is the same on both sites=
 +
==ipsec.conf==
 +
===Erklärung===
 +
*[[ipsec.conf Erklärung]]
 +
===Datei===
 
<pre>
 
<pre>
 
conn s2s
 
conn s2s
 
     authby=secret
 
     authby=secret
     keyexchange=ikev2
+
     keyexchange=ikev1
     left=192.168.244.93
+
     left=10.82.227.12
     leftid=@alice
+
     leftid=10.82.227.12
     leftsubnet=172.16.93.0/24
+
     leftsubnet=10.82.243.0/24
     right=192.168.244.59
+
    mobike=no
     rightid=@tiazel
+
     right=10.82.227.22
     rightsubnet=172.16.59.0/24
+
     rightid=10.82.227.22
     ike=aes256-sha1-modp1536
+
     rightsubnet=10.82.244.0/24
     esp=aes256-sha1-modp1536
+
     ike=aes256-sha256-modp4096!
 +
     esp=aes256-sha256-modp4096!
 
     auto=start
 
     auto=start
 
</pre>
 
</pre>
*/etc/ipsec.secrets
+
 
  @tiazel @alice : PSK "suxer"
+
==ipsec.secrets==
==alice==
+
;ID Kombination mit Authentifizierungsmethodes
 +
  10.82.227.12 10.82.227.22 : PSK "suxer"
 +
 
 +
=Handling=
 +
=Up=
 
*ipsec up  s2s
 
*ipsec up  s2s
 
<pre>
 
<pre>
initiating IKE_SA s2s[3] to 192.168.244.59
+
initiating Main Mode IKE_SA s2s[3] to 10.82.227.22
generating IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) ]
+
generating ID_PROT request 0 [ SA V V V V V ]
sending packet: from 192.168.244.93[500] to 192.168.244.59[500] (1004 bytes)
+
sending packet: from 10.82.227.12[500] to 10.82.227.22[500] (180 bytes)
received packet: from 192.168.244.59[500] to 192.168.244.93[500] (376 bytes)
+
received packet: from 10.82.227.22[500] to 10.82.227.12[500] (160 bytes)
parsed IKE_SA_INIT response 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(MULT_AUTH) ]
+
parsed ID_PROT response 0 [ SA V V V V ]
authentication of 'alice' (myself) with pre-shared key
+
received XAuth vendor ID
establishing CHILD_SA s2s
+
received DPD vendor ID
generating IKE_AUTH request 1 [ IDi N(INIT_CONTACT) IDr AUTH SA TSi TSr N(MOBIKE_SUP) N(ADD_4_ADDR) N(MULT_AUTH) N(EAP_ONLY) ]
+
received FRAGMENTATION vendor ID
sending packet: from 192.168.244.93[4500] to 192.168.244.59[4500] (364 bytes)
+
received NAT-T (RFC 3947) vendor ID
received packet: from 192.168.244.59[4500] to 192.168.244.93[4500] (236 bytes)
+
selected proposal: IKE:AES_CBC_256/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_4096
parsed IKE_AUTH response 1 [ IDr AUTH SA TSi TSr N(AUTH_LFT) N(MOBIKE_SUP) N(ADD_4_ADDR) ]
+
generating ID_PROT request 0 [ KE No NAT-D NAT-D ]
authentication of 'tiazel' with pre-shared key successful
+
sending packet: from 10.82.227.12[500] to 10.82.227.22[500] (652 bytes)
IKE_SA s2s[3] established between 192.168.244.93[alice]...192.168.244.59[tiazel]
+
received packet: from 10.82.227.22[500] to 10.82.227.12[500] (652 bytes)
scheduling reauthentication in 9834s
+
parsed ID_PROT response 0 [ KE No NAT-D NAT-D ]
maximum IKE_SA lifetime 10374s
+
generating ID_PROT request 0 [ ID HASH N(INITIAL_CONTACT) ]
 +
sending packet: from 10.82.227.12[500] to 10.82.227.22[500] (108 bytes)
 +
received packet: from 10.82.227.22[500] to 10.82.227.12[500] (92 bytes)
 +
parsed ID_PROT response 0 [ ID HASH ]
 +
IKE_SA s2s[3] established between 10.82.227.12[10.82.227.12]...10.82.227.22[10.82.227.22]
 +
scheduling reauthentication in 10142s
 +
maximum IKE_SA lifetime 10682s
 +
generating QUICK_MODE request 1581114031 [ HASH SA No KE ID ID ]
 +
sending packet: from 10.82.227.12[500] to 10.82.227.22[500] (716 bytes)
 +
received packet: from 10.82.227.22[500] to 10.82.227.12[500] (716 bytes)
 +
parsed QUICK_MODE response 1581114031 [ HASH SA No KE ID ID ]
 +
selected proposal: ESP:AES_CBC_256/HMAC_SHA2_256_128/MODP_4096/NO_EXT_SEQ
 +
CHILD_SA s2s{3} established with SPIs c2c20b47_i c1f461d9_o and TS 10.82.243.0/24 === 10.82.244.0/24
 
connection 's2s' established successfully
 
connection 's2s' established successfully
 
</pre>
 
</pre>
*tcpdump -ni eth0 port 500 or port 4500
+
 
 +
=Down=
 +
*ipsec down s2s
 
<pre>
 
<pre>
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
+
closing CHILD_SA s2s{3} with SPIs c2c20b47_i (0 bytes) c1f461d9_o (0 bytes) and TS 10.82.243.0/24 === 10.82.244.0/24
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
+
sending DELETE for ESP CHILD_SA with SPI c2c20b47
11:03:13.883570 IP 192.168.244.93.500 > 192.168.244.59.500: isakmp: parent_sa ikev2_init[I]
+
generating INFORMATIONAL_V1 request 2875265242 [ HASH D ]
11:03:13.892845 IP 192.168.244.59.500 > 192.168.244.93.500: isakmp: parent_sa ikev2_init[R]
+
sending packet: from 10.82.227.12[500] to 10.82.227.22[500] (92 bytes)
11:03:13.903029 IP 192.168.244.93.4500 > 192.168.244.59.4500: NONESP-encap: isakmp: child_sa  ikev2_auth[I]
+
deleting IKE_SA s2s[3] between 10.82.227.12[10.82.227.12]...10.82.227.22[10.82.227.22]
11:03:13.905576 IP 192.168.244.59.4500 > 192.168.244.93.4500: NONESP-encap: isakmp: child_sa  ikev2_auth[R]
+
sending DELETE for IKE_SA s2s[3]
 +
generating INFORMATIONAL_V1 request 510142709 [ HASH D ]
 +
sending packet: from 10.82.227.12[500] to 10.82.227.22[500] (108 bytes)
 +
IKE_SA [3] closed successfully
 
</pre>
 
</pre>
 +
=Status=
 +
*ipsec status  s2s
 +
Security Associations (1 up, 0 connecting):
 +
          s2s[4]: ESTABLISHED 7 seconds ago, 10.82.227.12[10.82.227.12]...10.82.227.22[10.82.227.22]
 +
          s2s{4}:  INSTALLED, TUNNEL, reqid 1, ESP SPIs: cef198fc_i c4de821a_o
 +
          s2s{4}:  10.82.243.0/24 === 10.82.244.0/24
 +
=TCPDump der Verbindung=
 +
*tcpdump -ni eth0 port 500 or  esp
 +
;up
 +
<pre>
 +
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
 +
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
 +
08:37:31.702968 IP 10.82.227.12.500 > 10.82.227.22.500: isakmp: phase 1 I ident
 +
08:37:31.707296 IP 10.82.227.22.500 > 10.82.227.12.500: isakmp: phase 1 R ident
 +
08:37:31.764500 IP 10.82.227.12.500 > 10.82.227.22.500: isakmp: phase 1 I ident
 +
08:37:31.888131 IP 10.82.227.22.500 > 10.82.227.12.500: isakmp: phase 1 R ident
 +
08:37:31.945758 IP 10.82.227.12.500 > 10.82.227.22.500: isakmp: phase 1 I ident[E]
 +
08:37:31.949075 IP 10.82.227.22.500 > 10.82.227.12.500: isakmp: phase 1 R ident[E]
 +
08:37:32.018782 IP 10.82.227.12.500 > 10.82.227.22.500: isakmp: phase 2/others I oakley-quick[E]
 +
08:37:32.128716 IP 10.82.227.22.500 > 10.82.227.12.500: isakmp: phase 2/others R oakley-quick[E]
 +
08:37:32.193586 IP 10.82.227.12.500 > 10.82.227.22.500: isakmp: phase 2/others I oakley-quick[E]
 +
</pre>
 +
down
 +
<pre>
 +
08:38:13.527180 IP 10.82.227.12.500 > 10.82.227.22.500: isakmp: phase 2/others I inf[E]
 +
08:38:13.527950 IP 10.82.227.12.500 > 10.82.227.22.500: isakmp: phase 2/others I inf[E]
 +
</pre>
 +
 
=Mehrere Subnetze=
 
=Mehrere Subnetze=
 
==alice und tiazel==
 
==alice und tiazel==

Version vom 5. September 2022, 09:01 Uhr


Config is the same on both sites

ipsec.conf

Erklärung

Datei

conn s2s
     authby=secret
     keyexchange=ikev1
     left=10.82.227.12
     leftid=10.82.227.12
     leftsubnet=10.82.243.0/24
     mobike=no
     right=10.82.227.22
     rightid=10.82.227.22
     rightsubnet=10.82.244.0/24
     ike=aes256-sha256-modp4096!
     esp=aes256-sha256-modp4096!
     auto=start

ipsec.secrets

ID Kombination mit Authentifizierungsmethodes
10.82.227.12 10.82.227.22  : PSK "suxer"

Handling

Up

  • ipsec up s2s
initiating Main Mode IKE_SA s2s[3] to 10.82.227.22
generating ID_PROT request 0 [ SA V V V V V ]
sending packet: from 10.82.227.12[500] to 10.82.227.22[500] (180 bytes)
received packet: from 10.82.227.22[500] to 10.82.227.12[500] (160 bytes)
parsed ID_PROT response 0 [ SA V V V V ]
received XAuth vendor ID
received DPD vendor ID
received FRAGMENTATION vendor ID
received NAT-T (RFC 3947) vendor ID
selected proposal: IKE:AES_CBC_256/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_4096
generating ID_PROT request 0 [ KE No NAT-D NAT-D ]
sending packet: from 10.82.227.12[500] to 10.82.227.22[500] (652 bytes)
received packet: from 10.82.227.22[500] to 10.82.227.12[500] (652 bytes)
parsed ID_PROT response 0 [ KE No NAT-D NAT-D ]
generating ID_PROT request 0 [ ID HASH N(INITIAL_CONTACT) ]
sending packet: from 10.82.227.12[500] to 10.82.227.22[500] (108 bytes)
received packet: from 10.82.227.22[500] to 10.82.227.12[500] (92 bytes)
parsed ID_PROT response 0 [ ID HASH ]
IKE_SA s2s[3] established between 10.82.227.12[10.82.227.12]...10.82.227.22[10.82.227.22]
scheduling reauthentication in 10142s
maximum IKE_SA lifetime 10682s
generating QUICK_MODE request 1581114031 [ HASH SA No KE ID ID ]
sending packet: from 10.82.227.12[500] to 10.82.227.22[500] (716 bytes)
received packet: from 10.82.227.22[500] to 10.82.227.12[500] (716 bytes)
parsed QUICK_MODE response 1581114031 [ HASH SA No KE ID ID ]
selected proposal: ESP:AES_CBC_256/HMAC_SHA2_256_128/MODP_4096/NO_EXT_SEQ
CHILD_SA s2s{3} established with SPIs c2c20b47_i c1f461d9_o and TS 10.82.243.0/24 === 10.82.244.0/24
connection 's2s' established successfully

Down

  • ipsec down s2s
closing CHILD_SA s2s{3} with SPIs c2c20b47_i (0 bytes) c1f461d9_o (0 bytes) and TS 10.82.243.0/24 === 10.82.244.0/24
sending DELETE for ESP CHILD_SA with SPI c2c20b47
generating INFORMATIONAL_V1 request 2875265242 [ HASH D ]
sending packet: from 10.82.227.12[500] to 10.82.227.22[500] (92 bytes)
deleting IKE_SA s2s[3] between 10.82.227.12[10.82.227.12]...10.82.227.22[10.82.227.22]
sending DELETE for IKE_SA s2s[3]
generating INFORMATIONAL_V1 request 510142709 [ HASH D ]
sending packet: from 10.82.227.12[500] to 10.82.227.22[500] (108 bytes)
IKE_SA [3] closed successfully

Status

  • ipsec status s2s
Security Associations (1 up, 0 connecting):
         s2s[4]: ESTABLISHED 7 seconds ago, 10.82.227.12[10.82.227.12]...10.82.227.22[10.82.227.22]
         s2s{4}:  INSTALLED, TUNNEL, reqid 1, ESP SPIs: cef198fc_i c4de821a_o
         s2s{4}:   10.82.243.0/24 === 10.82.244.0/24

TCPDump der Verbindung

  • tcpdump -ni eth0 port 500 or esp
up
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
08:37:31.702968 IP 10.82.227.12.500 > 10.82.227.22.500: isakmp: phase 1 I ident
08:37:31.707296 IP 10.82.227.22.500 > 10.82.227.12.500: isakmp: phase 1 R ident
08:37:31.764500 IP 10.82.227.12.500 > 10.82.227.22.500: isakmp: phase 1 I ident
08:37:31.888131 IP 10.82.227.22.500 > 10.82.227.12.500: isakmp: phase 1 R ident
08:37:31.945758 IP 10.82.227.12.500 > 10.82.227.22.500: isakmp: phase 1 I ident[E]
08:37:31.949075 IP 10.82.227.22.500 > 10.82.227.12.500: isakmp: phase 1 R ident[E]
08:37:32.018782 IP 10.82.227.12.500 > 10.82.227.22.500: isakmp: phase 2/others I oakley-quick[E]
08:37:32.128716 IP 10.82.227.22.500 > 10.82.227.12.500: isakmp: phase 2/others R oakley-quick[E]
08:37:32.193586 IP 10.82.227.12.500 > 10.82.227.22.500: isakmp: phase 2/others I oakley-quick[E]

down

08:38:13.527180 IP 10.82.227.12.500 > 10.82.227.22.500: isakmp: phase 2/others I inf[E]
08:38:13.527950 IP 10.82.227.12.500 > 10.82.227.22.500: isakmp: phase 2/others I inf[E]

Mehrere Subnetze

alice und tiazel

  • /etc/ipsec.conf
conn s2s
     authby=secret
     keyexchange=ikev2
     left=192.168.244.93
     leftid=@alice
     leftsubnet=172.16.93.0/24,10.16.93.0/24
     right=192.168.244.59
     rightid=@tiazel
     rightsubnet=172.16.59.0/24,10.16.59.0/24
     ike=aes256-sha1-modp1536
     esp=aes256-sha1-modp1536
     auto=start
  • ipsec status
Security Associations (1 up, 0 connecting):
         s2s[4]: ESTABLISHED 80 seconds ago, 192.168.244.93[alice]...192.168.244.59[tiazel]
         s2s{4}:  INSTALLED, TUNNEL, ESP SPIs: c0087b2d_i c3cf4303_o
         s2s{4}:   172.16.93.0/24 10.16.93.0/24 === 172.16.59.0/24 10.16.59.0/24

Links