PRE-TEST

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

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

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

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

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

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

moon# expect-connection rw

carol# expect-connection home

carol# ipsec up home
initiating IKE_SA home[1] to 192.168.0.1
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.100[500] to 192.168.0.1[500] (924 bytes)
received packet: from 192.168.0.1[500] to 192.168.0.100[500] (305 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) N(MULT_AUTH) ]
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 'carol@strongswan.org' (myself) with RSA_EMSA_PKCS1_SHA2_256 successful
sending end entity cert "C=CH, O=strongSwan Project, OU=Research, CN=carol@strongswan.org"
establishing CHILD_SA home{1}
generating IKE_AUTH request 1 [ IDi CERT N(INIT_CONTACT) CERTREQ IDr AUTH CPRQ(ADDR) SA TSi TSr N(MOBIKE_SUP) N(ADD_6_ADDR) N(MULT_AUTH) N(EAP_ONLY) N(MSG_ID_SYN_SUP) ]
splitting IKE message (2032 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.100[4500] to 192.168.0.1[4500] (1236 bytes)
sending packet: from 192.168.0.100[4500] to 192.168.0.1[4500] (868 bytes)
received packet: from 192.168.0.1[4500] to 192.168.0.100[4500] (1236 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.1[4500] to 192.168.0.100[4500] (708 bytes)
parsed IKE_AUTH response 1 [ EF(2/2) ]
received fragment #2 of 2, reassembled fragmented IKE message (1872 bytes)
parsed IKE_AUTH response 1 [ IDr CERT AUTH CPRP(ADDR) SA TSi TSr N(AUTH_LFT) N(MOBIKE_SUP) N(ADD_4_ADDR) N(ADD_6_ADDR) N(ADD_6_ADDR) ]
received end entity cert "C=CH, O=strongSwan Project, CN=moon.strongswan.org"
  using certificate "C=CH, O=strongSwan Project, CN=moon.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=moon.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 'moon.strongswan.org' with RSA_EMSA_PKCS1_SHA2_256 successful
installing new virtual IP 10.3.0.1
received AUTH_LIFETIME of 3275s, scheduling reauthentication in 3095s
peer supports MOBIKE
IKE_SA home[1] established between 192.168.0.100[carol@strongswan.org]...192.168.0.1[moon.strongswan.org]
reauthentication already scheduled in 3095s
maximum IKE_SA lifetime 3275s
selected proposal: ESP:AES_CBC_128/HMAC_SHA2_256_128/NO_EXT_SEQ
CHILD_SA home{1} established with SPIs c736f3cf_i c88d07d1_o and TS 10.3.0.1/32 === 10.1.0.0/16
connection 'home' established successfully

dave# expect-connection home

dave# ipsec up home
initiating IKE_SA home[1] to 192.168.0.1
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.200[500] to 192.168.0.1[500] (924 bytes)
received packet: from 192.168.0.1[500] to 192.168.0.200[500] (305 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) N(MULT_AUTH) ]
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 'dave@strongswan.org' (myself) with RSA_EMSA_PKCS1_SHA2_256 successful
sending end entity cert "C=CH, O=strongSwan Project, OU=Accounting, CN=dave@strongswan.org"
establishing CHILD_SA home{1}
generating IKE_AUTH request 1 [ IDi CERT N(INIT_CONTACT) CERTREQ IDr AUTH CPRQ(ADDR) SA TSi TSr N(MOBIKE_SUP) N(ADD_6_ADDR) N(MULT_AUTH) N(EAP_ONLY) N(MSG_ID_SYN_SUP) ]
splitting IKE message (2032 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.200[4500] to 192.168.0.1[4500] (1236 bytes)
sending packet: from 192.168.0.200[4500] to 192.168.0.1[4500] (868 bytes)
received packet: from 192.168.0.1[4500] to 192.168.0.200[4500] (1236 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.1[4500] to 192.168.0.200[4500] (708 bytes)
parsed IKE_AUTH response 1 [ EF(2/2) ]
received fragment #2 of 2, reassembled fragmented IKE message (1872 bytes)
parsed IKE_AUTH response 1 [ IDr CERT AUTH CPRP(ADDR) SA TSi TSr N(AUTH_LFT) N(MOBIKE_SUP) N(ADD_4_ADDR) N(ADD_6_ADDR) N(ADD_6_ADDR) ]
received end entity cert "C=CH, O=strongSwan Project, CN=moon.strongswan.org"
  using certificate "C=CH, O=strongSwan Project, CN=moon.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=moon.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 'moon.strongswan.org' with RSA_EMSA_PKCS1_SHA2_256 successful
installing new virtual IP 10.3.0.2
received AUTH_LIFETIME of 3411s, scheduling reauthentication in 3231s
peer supports MOBIKE
IKE_SA home[1] established between 192.168.0.200[dave@strongswan.org]...192.168.0.1[moon.strongswan.org]
reauthentication already scheduled in 3231s
maximum IKE_SA lifetime 3411s
selected proposal: ESP:AES_CBC_128/HMAC_SHA2_256_128/NO_EXT_SEQ
CHILD_SA home{1} established with SPIs c4945324_i ce7f716f_o and TS 10.3.0.2/32 === 10.1.0.0/16
connection 'home' established successfully


TEST

carol# cat /var/log/daemon.log | grep 'installing new virtual IP 10.3.0.1' [YES]
Mar 10 19:37:48 carol charon: 14[IKE] installing new virtual IP 10.3.0.1

carol# ip addr list dev eth0 | grep '10.3.0.1' [YES]
    inet 10.3.0.1/32 scope global eth0

carol# ip route list table 220 | grep '10.1.0.0/16.*src 10.3.0.1' [YES]
10.1.0.0/16 via 192.168.0.1 dev eth0 proto static src 10.3.0.1 

carol# ipsec status 2> /dev/null | grep 'home.*ESTABLISHED.*carol@strongswan.org.*moon.strongswan.org' [YES]
        home[1]: ESTABLISHED 0 seconds ago, 192.168.0.100[carol@strongswan.org]...192.168.0.1[moon.strongswan.org]

carol# ipsec status 2> /dev/null | grep 'home.*INSTALLED, TUNNEL' [YES]
        home{1}:  INSTALLED, TUNNEL, reqid 1, ESP SPIs: c736f3cf_i c88d07d1_o

carol# ping -c 1 10.1.0.10 | grep '64 bytes from 10.1.0.10: icmp_.eq=1' [YES]
64 bytes from 10.1.0.10: icmp_seq=1 ttl=63 time=1.02 ms

dave# cat /var/log/daemon.log | grep 'installing new virtual IP 10.3.0.2' [YES]
Mar 10 19:37:48 dave charon: 13[IKE] installing new virtual IP 10.3.0.2

dave# ip addr list dev eth0 | grep '10.3.0.2' [YES]
    inet 10.3.0.2/32 scope global eth0

dave# ip route list table 220 | grep '10.1.0.0/16.*src 10.3.0.2' [YES]
10.1.0.0/16 via 192.168.0.1 dev eth0 proto static src 10.3.0.2 

dave# ipsec status 2> /dev/null | grep 'home.*ESTABLISHED.*dave@strongswan.org.*moon.strongswan.org' [YES]
        home[1]: ESTABLISHED 0 seconds ago, 192.168.0.200[dave@strongswan.org]...192.168.0.1[moon.strongswan.org]

dave# ipsec status 2> /dev/null | grep 'home.*INSTALLED, TUNNEL' [YES]
        home{1}:  INSTALLED, TUNNEL, reqid 1, ESP SPIs: c4945324_i ce7f716f_o

dave# ping -c 1 10.1.0.10 | grep '64 bytes from 10.1.0.10: icmp_.eq=1' [YES]
64 bytes from 10.1.0.10: icmp_seq=1 ttl=63 time=1.17 ms

moon# cat /var/log/daemon.log | grep 'adding virtual IP address pool' [YES]
Mar 10 19:37:47 moon charon: 02[CFG] adding virtual IP address pool 10.3.0.0/28

moon# cat /var/log/daemon.log | grep 'peer requested virtual IP %any' [YES]
Mar 10 19:37:47 moon charon: 07[IKE] peer requested virtual IP %any
Mar 10 19:37:48 moon charon: 14[IKE] peer requested virtual IP %any

moon# cat /var/log/daemon.log | grep 'assigning virtual IP' [YES]
Mar 10 19:37:47 moon charon: 07[IKE] assigning virtual IP 10.3.0.1 to peer 'carol@strongswan.org'
Mar 10 19:37:48 moon charon: 14[IKE] assigning virtual IP 10.3.0.2 to peer 'dave@strongswan.org'

moon# ipsec leases 10.3.0.0/28 2> /dev/null | grep '2/14, 2 online' [YES]
Leases in pool '10.3.0.0/28', usage: 2/14, 2 online

moon# ipsec leases 10.3.0.0/28 10.3.0.1 2> /dev/null | grep 'carol@strongswan.org' [YES]
         10.3.0.1   online   'carol@strongswan.org'

moon# ipsec leases 10.3.0.0/28 10.3.0.2 2> /dev/null | grep 'dave@strongswan.org' [YES]
         10.3.0.2   online   'dave@strongswan.org'

moon# ipsec status 2> /dev/null | grep 'rw\[1]: ESTABLISHED.*moon.strongswan.org.*carol@strongswan.org' [YES]
          rw[1]: ESTABLISHED 1 second ago, 192.168.0.1[moon.strongswan.org]...192.168.0.100[carol@strongswan.org]

moon# ipsec status 2> /dev/null | grep 'rw\[2]: ESTABLISHED.*moon.strongswan.org.*dave@strongswan.org' [YES]
          rw[2]: ESTABLISHED 0 seconds ago, 192.168.0.1[moon.strongswan.org]...192.168.0.200[dave@strongswan.org]

moon# ipsec status 2> /dev/null | grep 'rw[{]1}.*INSTALLED, TUNNEL' [ESP]
          rw{1}:  INSTALLED, TUNNEL, reqid 1, ESP SPIs: c88d07d1_i c736f3cf_o

moon# ipsec status 2> /dev/null | grep 'rw[{]2}.*INSTALLED, TUNNEL' [ESP]
          rw{2}:  INSTALLED, TUNNEL, reqid 2, ESP SPIs: ce7f716f_i c4945324_o

moon# killall tcpdump

moon# cat /tmp/tcpdump.log | grep 'IP carol.strongswan.org > moon.strongswan.org: ESP' [YES]
19:37:48.339980 IP carol.strongswan.org > moon.strongswan.org: ESP(spi=0xc88d07d1,seq=0x1), length 136

moon# cat /tmp/tcpdump.log | grep 'IP moon.strongswan.org > carol.strongswan.org: ESP' [YES]
19:37:48.340552 IP moon.strongswan.org > carol.strongswan.org: ESP(spi=0xc736f3cf,seq=0x1), length 136

moon# cat /tmp/tcpdump.log | grep 'IP dave.strongswan.org > moon.strongswan.org: ESP' [YES]
19:37:48.532138 IP dave.strongswan.org > moon.strongswan.org: ESP(spi=0xce7f716f,seq=0x1), length 136

moon# cat /tmp/tcpdump.log | grep 'IP moon.strongswan.org > dave.strongswan.org: ESP' [YES]
19:37:48.532826 IP moon.strongswan.org > dave.strongswan.org: ESP(spi=0xc4945324,seq=0x1), length 136

alice# killall tcpdump

alice# cat /tmp/tcpdump.log | grep 'IP carol1.strongswan.org > alice.strongswan.org: ICMP echo request' [YES]
19:37:48.720290 IP carol1.strongswan.org > alice.strongswan.org: ICMP echo request, id 36330, seq 1, length 64

alice# cat /tmp/tcpdump.log | grep 'IP alice.strongswan.org > carol1.strongswan.org: ICMP echo reply' [YES]
19:37:48.720330 IP alice.strongswan.org > carol1.strongswan.org: ICMP echo reply, id 36330, seq 1, length 64

alice# cat /tmp/tcpdump.log | grep 'IP dave1.strongswan.org > alice.strongswan.org: ICMP echo request' [YES]
19:37:48.912531 IP dave1.strongswan.org > alice.strongswan.org: ICMP echo request, id 22844, seq 1, length 64

alice# cat /tmp/tcpdump.log | grep 'IP alice.strongswan.org > dave1.strongswan.org: ICMP echo reply' [YES]
19:37:48.912567 IP alice.strongswan.org > dave1.strongswan.org: ICMP echo reply, id 22844, seq 1, length 64


POST-TEST

carol# ipsec stop
Stopping strongSwan IPsec...

dave# ipsec stop
Stopping strongSwan IPsec...

moon# ipsec stop
Stopping strongSwan IPsec...

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

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

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