PRE-TEST

moon# iptables-restore < /etc/iptables.rules

sun# iptables-restore < /etc/iptables.rules

sun# ipsec start
Starting strongSwan 6.0.1 IPsec [starter]...

moon# ipsec start
Starting strongSwan 6.0.1 IPsec [starter]...

sun# expect-connection host-host

moon# expect-connection host-host

moon# ipsec up host-host
initiating IKE_SA host-host[1] to 192.168.0.2
generating IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(FRAG_SUP) N(HASH_ALG) N(REDIR_SUP) ]
sending packet: from 192.168.0.1[500] to 192.168.0.2[500] (924 bytes)
received packet: from 192.168.0.2[500] to 192.168.0.1[500] (297 bytes)
parsed IKE_SA_INIT response 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) CERTREQ N(FRAG_SUP) N(HASH_ALG) N(CHDLESS_SUP) ]
selected proposal: IKE:AES_CBC_128/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/ECP_256
received cert request for "C=CH, O=strongSwan Project, CN=strongSwan Root CA"
sending cert request for "C=CH, O=strongSwan Project, CN=strongSwan Root CA"
authentication of 'moon.strongswan.org' (myself) with RSA_EMSA_PKCS1_SHA2_256 successful
sending end entity cert "C=CH, O=strongSwan Project, CN=moon.strongswan.org"
establishing CHILD_SA host-host{1}
generating IKE_AUTH request 1 [ IDi CERT N(INIT_CONTACT) CERTREQ IDr AUTH N(USE_TRANSP) SA TSi TSr N(EAP_ONLY) N(MSG_ID_SYN_SUP) ]
splitting IKE message (1968 bytes) into 2 fragments
generating IKE_AUTH request 1 [ EF(1/2) ]
generating IKE_AUTH request 1 [ EF(2/2) ]
sending packet: from 192.168.0.1[500] to 192.168.0.2[500] (1252 bytes)
sending packet: from 192.168.0.1[500] to 192.168.0.2[500] (788 bytes)
received packet: from 192.168.0.2[500] to 192.168.0.1[500] (1252 bytes)
parsed IKE_AUTH response 1 [ EF(1/2) ]
received fragment #1 of 2, waiting for complete IKE message
received packet: from 192.168.0.2[500] to 192.168.0.1[500] (596 bytes)
parsed IKE_AUTH response 1 [ EF(2/2) ]
received fragment #2 of 2, reassembled fragmented IKE message (1776 bytes)
parsed IKE_AUTH response 1 [ IDr CERT AUTH N(USE_TRANSP) SA TSi TSr ]
received end entity cert "C=CH, O=strongSwan Project, CN=sun.strongswan.org"
  using certificate "C=CH, O=strongSwan Project, CN=sun.strongswan.org"
  using trusted ca certificate "C=CH, O=strongSwan Project, CN=strongSwan Root CA"
  reached self-signed root ca with a path length of 0
checking certificate status of "C=CH, O=strongSwan Project, CN=sun.strongswan.org"
  fetching crl from 'http://crl.strongswan.org/strongswan.crl' ...
  using trusted certificate "C=CH, O=strongSwan Project, CN=strongSwan Root CA"
  crl correctly signed by "C=CH, O=strongSwan Project, CN=strongSwan Root CA"
  crl is valid: until Mar 25 18:47:43 2025
certificate status is good
authentication of 'sun.strongswan.org' with RSA_EMSA_PKCS1_SHA2_256 successful
IKE_SA host-host[1] established between 192.168.0.1[moon.strongswan.org]...192.168.0.2[sun.strongswan.org]
scheduling reauthentication in 3378s
maximum IKE_SA lifetime 3558s
selected proposal: ESP:AES_CBC_128/HMAC_SHA2_256_128/NO_EXT_SEQ
CHILD_SA host-host{1} established with SPIs c63e4e5d_i c24ffe1f_o and TS 192.168.0.1/32 === 192.168.0.2/32
connection 'host-host' established successfully


TEST

moon# ipsec status 2> /dev/null | grep 'host-host.*ESTABLISHED.*moon.strongswan.org.*sun.strongswan.org' [YES]
   host-host[1]: ESTABLISHED 0 seconds ago, 192.168.0.1[moon.strongswan.org]...192.168.0.2[sun.strongswan.org]

sun# ipsec status 2> /dev/null | grep 'host-host.*ESTABLISHED.*sun.strongswan.org.*moon.strongswan.org' [YES]
   host-host[1]: ESTABLISHED 1 second ago, 192.168.0.2[sun.strongswan.org]...192.168.0.1[moon.strongswan.org]

moon# ipsec status 2> /dev/null | grep 'host-host.*INSTALLED, TRANSPORT' [YES]
   host-host{1}:  INSTALLED, TRANSPORT, reqid 1, ESP SPIs: c63e4e5d_i c24ffe1f_o

sun# ipsec status 2> /dev/null | grep 'host-host.*INSTALLED, TRANSPORT' [YES]
   host-host{1}:  INSTALLED, TRANSPORT, reqid 1, ESP SPIs: c24ffe1f_i c63e4e5d_o

moon# ping -c 1 192.168.0.2 | grep '64 bytes from 192.168.0.2: icmp_.eq=1' [YES]
64 bytes from 192.168.0.2: icmp_seq=1 ttl=64 time=0.660 ms

sun# killall tcpdump

sun# cat /tmp/tcpdump.log | grep 'IP moon.strongswan.org > sun.strongswan.org: ESP' [YES]
19:37:42.221539 IP moon.strongswan.org > sun.strongswan.org: ESP(spi=0xc24ffe1f,seq=0x1), length 120

sun# cat /tmp/tcpdump.log | grep 'IP sun.strongswan.org > moon.strongswan.org: ESP' [YES]
19:37:42.221641 IP sun.strongswan.org > moon.strongswan.org: ESP(spi=0xc63e4e5d,seq=0x1), length 120


POST-TEST

moon# ipsec stop
Stopping strongSwan IPsec...

sun# ipsec stop
Stopping strongSwan IPsec...

moon# iptables-restore < /etc/iptables.flush

sun# iptables-restore < /etc/iptables.flush