testing: Migrate ikev2-stroke-bye scenarios to vici
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
The roadwarriors <b>alice</b> and <b>venus</b> sitting behind the router <b>moon</b> set up
|
||||
tunnels to gateway <b>sun</b>. Since both roadwarriors possess the same 10.1.0.0/25 subnet,
|
||||
gateway <b>sun</b> uses Source NAT after ESP decryption to map these subnets to 10.3.0.10
|
||||
and 10.3.0.20, respectively.
|
||||
<p/>
|
||||
In order to differentiate between the tunnels to <b>alice</b> and <b>venus</b>, respectively,
|
||||
<b>XFRM marks</b> are defined for both the inbound and outbound IPsec SAs and policies using
|
||||
the <b>mark_in</b> and <b>mark_out</b> options. With the <b>set_mark_in</b> option, the
|
||||
corresponding mark is applied to the inbound packets after decryption. Return traffic is
|
||||
marked via <b>iptables -t mangle</b> rules in the PREROUTING chain.
|
||||
<p/>
|
||||
In order to test the tunnel, the hosts <b>alice</b> and <b>venus</b> ping the client
|
||||
<b>bob</b> behind the gateway <b>sun</b>.
|
||||
@@ -0,0 +1,14 @@
|
||||
alice::swanctl --list-sas --raw 2> /dev/null::home.*version=2 state=ESTABLISHED local-host=PH_IP_ALICE local-port=4500 [email protected] remote-host=PH_IP_SUN remote-port=4500 remote-id=sun.strongswan.org initiator=yes.*encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=CURVE_25519.*child-sas.*home.*reqid=1 state=INSTALLED mode=TUNNEL protocol=ESP.*encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[10.1.0.0/25] remote-ts=\[10.2.0.0/16]::YES
|
||||
venus::swanctl --list-sas --raw 2> /dev/null::home.*version=2 state=ESTABLISHED local-host=PH_IP_VENUS local-port=4500 local-id=venus.strongswan.org remote-host=PH_IP_SUN remote-port=4500 remote-id=sun.strongswan.org initiator=yes.*encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=CURVE_25519.*child-sas.*home.*reqid=1 state=INSTALLED mode=TUNNEL protocol=ESP.*encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[10.1.0.0/25] remote-ts=\[10.2.0.0/16]::YES
|
||||
sun:: swanctl --list-sas --raw --ike-id 1 2> /dev/null::alice.*version=2 state=ESTABLISHED local-host=PH_IP_SUN local-port=4500 local-id=sun.strongswan.org remote-host=PH_IP_ALICE.*[email protected].*encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=CURVE_25519.*child-sas.*name=home.*reqid=1 state=INSTALLED mode=TUNNEL protocol=ESP.*mark-in=0000000a mark-out=0000000b encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[10.2.0.0/16] remote-ts=\[10.1.0.0/25]::YES
|
||||
sun:: swanctl --list-sas --raw --ike-id 2 2> /dev/null::venus.*version=2 state=ESTABLISHED local-host=PH_IP_SUN local-port=4500 local-id=sun.strongswan.org remote-host=PH_IP_VENUS.*remote-id=venus.strongswan.org.*encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=CURVE_25519.*child-sas.*name=home.*reqid=2 state=INSTALLED mode=TUNNEL protocol=ESP.*mark-in=00000014 mark-out=00000015 encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[10.2.0.0/16] remote-ts=\[10.1.0.0/25]::YES
|
||||
alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_.eq=1::YES
|
||||
venus::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_.eq=1::YES
|
||||
moon::tcpdump::IP alice.strongswan.org > sun.strongswan.org: ESP::YES
|
||||
moon::tcpdump::IP venus.strongswan.org > sun.strongswan.org: ESP::YES
|
||||
moon::tcpdump::IP sun.strongswan.org > alice.strongswan.org: ESP::YES
|
||||
moon::tcpdump::IP sun.strongswan.org > venus.strongswan.org: ESP::YES
|
||||
bob::tcpdump::10.3.0.10 > bob.strongswan.org: ICMP echo request::YES
|
||||
bob::tcpdump::10.3.0.20 > bob.strongswan.org: ICMP echo request::YES
|
||||
bob::tcpdump::bob.strongswan.org > 10.3.0.10: ICMP echo reply::YES
|
||||
bob::tcpdump::bob.strongswan.org > 10.3.0.20: ICMP echo reply::YES
|
||||
@@ -0,0 +1,5 @@
|
||||
# /etc/strongswan.conf - strongSwan configuration file
|
||||
|
||||
charon {
|
||||
load = random nonce aes sha1 sha2 pem pkcs1 curve25519 gmp x509 curl revocation hmac vici kernel-netlink socket-default updown
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
connections {
|
||||
|
||||
home {
|
||||
remote_addrs = PH_IP_SUN
|
||||
|
||||
local {
|
||||
auth = pubkey
|
||||
certs = aliceCert.pem
|
||||
id = [email protected]
|
||||
}
|
||||
remote {
|
||||
auth = pubkey
|
||||
id = sun.strongswan.org
|
||||
}
|
||||
children {
|
||||
home {
|
||||
local_ts = 10.1.0.0/25
|
||||
remote_ts = 10.2.0.0/16
|
||||
|
||||
updown = /usr/local/libexec/ipsec/_updown iptables
|
||||
hostaccess = yes
|
||||
esp_proposals = aes128gcm128-x25519
|
||||
}
|
||||
}
|
||||
version = 2
|
||||
proposals = aes128-sha256-x25519
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
# /etc/strongswan.conf - strongSwan configuration file
|
||||
|
||||
charon {
|
||||
load = random nonce aes sha1 sha2 pem pkcs1 curve25519 gmp x509 curl revocation hmac vici kernel-netlink socket-default updown
|
||||
syslog {
|
||||
daemon {
|
||||
knl = 2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
connections {
|
||||
|
||||
alice : connections.home {
|
||||
remote {
|
||||
id = [email protected]
|
||||
}
|
||||
children {
|
||||
home {
|
||||
mark_in = 10/0xffffffff
|
||||
set_mark_in = %same
|
||||
mark_out = 11/0xffffffff
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
venus : connections.home {
|
||||
remote {
|
||||
id = venus.strongswan.org
|
||||
}
|
||||
children {
|
||||
home {
|
||||
mark_in = 20 # 0xffffffff is used by default
|
||||
set_mark_in = %same
|
||||
mark_out = 21 # 0xffffffff is used by default
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
home {
|
||||
local_addrs = PH_IP_SUN
|
||||
|
||||
local {
|
||||
auth = pubkey
|
||||
certs = sunCert.pem
|
||||
id = sun.strongswan.org
|
||||
}
|
||||
remote {
|
||||
auth = pubkey
|
||||
}
|
||||
children {
|
||||
home {
|
||||
local_ts = 10.2.0.0/16
|
||||
remote_ts = 0.0.0.0/0
|
||||
|
||||
updown = /usr/local/libexec/ipsec/_updown iptables
|
||||
esp_proposals = aes128gcm128-x25519
|
||||
}
|
||||
}
|
||||
version = 2
|
||||
proposals = aes128-sha256-x25519
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# /etc/strongswan.conf - strongSwan configuration file
|
||||
|
||||
charon {
|
||||
load = random nonce aes sha1 sha2 pem pkcs1 curve25519 gmp x509 curl revocation hmac vici kernel-netlink socket-default updown
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
connections {
|
||||
|
||||
home {
|
||||
remote_addrs = PH_IP_SUN
|
||||
|
||||
local {
|
||||
auth = pubkey
|
||||
certs = venusCert.pem
|
||||
id = venus.strongswan.org
|
||||
}
|
||||
remote {
|
||||
auth = pubkey
|
||||
id = sun.strongswan.org
|
||||
}
|
||||
children {
|
||||
home {
|
||||
local_ts = 10.1.0.0/25
|
||||
remote_ts = 10.2.0.0/16
|
||||
|
||||
updown = /usr/local/libexec/ipsec/_updown iptables
|
||||
hostaccess = yes
|
||||
esp_proposals = aes128gcm128-x25519
|
||||
}
|
||||
}
|
||||
version = 2
|
||||
proposals = aes128-sha256-x25519
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
sun::iptables -t mangle -v -n -L PREROUTING
|
||||
sun::systemctl stop strongswan
|
||||
alice::systemctl stop strongswan
|
||||
venus::systemctl stop strongswan
|
||||
alice::iptables-restore < /etc/iptables.flush
|
||||
venus::iptables-restore < /etc/iptables.flush
|
||||
sun::iptables-restore < /etc/iptables.flush
|
||||
sun::ip route del 10.1.0.0/16 via PH_IP_MOON
|
||||
winnetou::ip route del 10.1.0.0/16 via PH_IP_MOON
|
||||
@@ -0,0 +1,20 @@
|
||||
alice::iptables-restore < /etc/iptables.rules
|
||||
venus::iptables-restore < /etc/iptables.rules
|
||||
sun::iptables-restore < /etc/iptables.rules
|
||||
winnetou::ip route add 10.1.0.0/16 via PH_IP_MOON
|
||||
sun::ip route add 10.1.0.0/16 via PH_IP_MOON
|
||||
# NAT client traffic to distinct virtual IPs
|
||||
sun::iptables -t nat -A POSTROUTING -o eth1 -m mark --mark 10 -j SNAT --to 10.3.0.10
|
||||
sun::iptables -t nat -A POSTROUTING -o eth1 -m mark --mark 20 -j SNAT --to 10.3.0.20
|
||||
# mark the return traffic accordingly
|
||||
sun::iptables -t mangle -A PREROUTING -d 10.3.0.10 -j MARK --set-mark 11
|
||||
sun::iptables -t mangle -A PREROUTING -d 10.3.0.20 -j MARK --set-mark 21
|
||||
sun::systemctl start strongswan
|
||||
alice::systemctl start strongswan
|
||||
venus::systemctl start strongswan
|
||||
sun::expect-connection alice
|
||||
alice::expect-connection home
|
||||
alice::swanctl --initiate --child home
|
||||
sun::expect-connection venus
|
||||
venus::expect-connection home
|
||||
venus::swanctl --initiate --child home
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This configuration file provides information on the
|
||||
# guest instances used for this test
|
||||
|
||||
# All guest instances that are required for this test
|
||||
#
|
||||
VIRTHOSTS="alice venus moon winnetou sun bob"
|
||||
|
||||
# Corresponding block diagram
|
||||
#
|
||||
DIAGRAM="a-v-m-w-s-b.png"
|
||||
|
||||
# Guest instances on which tcpdump is to be started
|
||||
#
|
||||
TCPDUMPHOSTS="moon bob"
|
||||
|
||||
# Guest instances on which IPsec is started
|
||||
# Used for IPsec logging purposes
|
||||
#
|
||||
IPSECHOSTS="alice venus sun"
|
||||
|
||||
# charon controlled by swanctl
|
||||
#
|
||||
SWANCTL=1
|
||||
Reference in New Issue
Block a user