testing: Added route-based/rw-shared-vti scenario
authorRobin McCorkell <robin@mccorkell.me.uk>
Wed, 29 Nov 2017 11:55:49 +0000 (11:55 +0000)
committerTobias Brunner <tobias@strongswan.org>
Fri, 22 Dec 2017 09:22:47 +0000 (10:22 +0100)
testing/tests/route-based/rw-shared-vti/description.txt [new file with mode: 0644]
testing/tests/route-based/rw-shared-vti/evaltest.dat [new file with mode: 0644]
testing/tests/route-based/rw-shared-vti/hosts/carol/etc/strongswan.conf [new file with mode: 0755]
testing/tests/route-based/rw-shared-vti/hosts/carol/etc/swanctl/swanctl.conf [new file with mode: 0755]
testing/tests/route-based/rw-shared-vti/hosts/dave/etc/strongswan.conf [new file with mode: 0755]
testing/tests/route-based/rw-shared-vti/hosts/dave/etc/swanctl/swanctl.conf [new file with mode: 0755]
testing/tests/route-based/rw-shared-vti/hosts/moon/etc/strongswan.conf [new file with mode: 0644]
testing/tests/route-based/rw-shared-vti/hosts/moon/etc/swanctl/swanctl.conf [new file with mode: 0755]
testing/tests/route-based/rw-shared-vti/posttest.dat [new file with mode: 0644]
testing/tests/route-based/rw-shared-vti/pretest.dat [new file with mode: 0644]
testing/tests/route-based/rw-shared-vti/test.conf [new file with mode: 0644]

diff --git a/testing/tests/route-based/rw-shared-vti/description.txt b/testing/tests/route-based/rw-shared-vti/description.txt
new file mode 100644 (file)
index 0000000..fa11b2d
--- /dev/null
@@ -0,0 +1,12 @@
+The roadwarriors <b>carol</b> and <b>dave</b> set up a connection each to
+gateway <b>moon</b>. Both <b>carol</b> and <b>dave</b> request a <b>virtual
+IP</b> via the IKEv2 configuration payload.
+<p/>
+The gateway <b>moon</b> uses <b>route-based forwarding</b> with <b>VTI
+tunnels</b>, with firewall rules to allow traffic to pass. The IKE daemon is
+configured to not install routes with <em>charon.install_routes=0</em>, and a
+static route is installed for the virtual IP subnet on the VTI device.
+<p/>
+Both <b>carol</b> and <b>dave</b> ping the client <b>alice</b> behind the
+gateway <b>moon</b>. The source IP addresses of the two pings will be the
+virtual IPs <b>carol1</b> and <b>dave1</b>, respectively.
diff --git a/testing/tests/route-based/rw-shared-vti/evaltest.dat b/testing/tests/route-based/rw-shared-vti/evaltest.dat
new file mode 100644 (file)
index 0000000..f693103
--- /dev/null
@@ -0,0 +1,10 @@
+carol::swanctl --list-sas --raw 2> /dev/null::home.*version=2 state=ESTABLISHED local-host=PH_IP_CAROL local-port=4500 local-id=carol@strongswan.org remote-host=PH_IP_MOON remote-port=4500 remote-id=moon.strongswan.org initiator=yes.*child-sas.*home.*state=INSTALLED mode=TUNNEL.*ESP.*local-ts=\[10.3.0.1/32] remote-ts=\[10.1.0.0/16]::YES
+dave:: swanctl --list-sas --raw 2> /dev/null::home.*version=2 state=ESTABLISHED local-host=PH_IP_DAVE local-port=4500 local-id=dave@strongswan.org remote-host=PH_IP_MOON remote-port=4500 remote-id=moon.strongswan.org initiator=yes.*child-sas.*home.*state=INSTALLED mode=TUNNEL.*ESP.*local-ts=\[10.3.0.2/32] remote-ts=\[10.1.0.0/16]::YES
+moon:: swanctl --list-sas --ike-id 1 --raw 2> /dev/null::rw.*version=2 state=ESTABLISHED local-host=PH_IP_MOON local-port=4500 local-id=moon.strongswan.org remote-host=PH_IP_CAROL remote-port=4500 remote-id=carol@strongswan.org.*child-sas.*net.*reqid=1 state=INSTALLED mode=TUNNEL.*ESP.*local-ts=\[10.1.0.0/16] remote-ts=\[10.3.0.1/32]::YES
+moon:: swanctl --list-sas --ike-id 2 --raw 2> /dev/null::rw.*version=2 state=ESTABLISHED local-host=PH_IP_MOON local-port=4500 local-id=moon.strongswan.org remote-host=PH_IP_DAVE remote-port=4500 remote-id=dave@strongswan.org.*child-sas.*net.*reqid=2 state=INSTALLED mode=TUNNEL.*ESP.*local-ts=\[10.1.0.0/16] remote-ts=\[10.3.0.2/32]::YES
+carol::ping -c 1 PH_IP_ALICE::64 bytes from PH_IP_ALICE: icmp_.eq=1::YES
+dave::ping -c 1 PH_IP_ALICE::64 bytes from PH_IP_ALICE: icmp_.eq=1::YES
+moon::tcpdump::IP moon.strongswan.org > carol.strongswan.org: ESP::YES
+moon::tcpdump::IP carol.strongswan.org > moon.strongswan.org: ESP::YES
+moon::tcpdump::IP moon.strongswan.org > dave.strongswan.org: ESP::YES
+moon::tcpdump::IP dave.strongswan.org > moon.strongswan.org: ESP::YES
diff --git a/testing/tests/route-based/rw-shared-vti/hosts/carol/etc/strongswan.conf b/testing/tests/route-based/rw-shared-vti/hosts/carol/etc/strongswan.conf
new file mode 100755 (executable)
index 0000000..ad4c18e
--- /dev/null
@@ -0,0 +1,9 @@
+# /etc/strongswan.conf - strongSwan configuration file
+
+swanctl {
+  load = pem pkcs1 x509 revocation constraints pubkey openssl random
+}
+
+charon-systemd {
+  load = random nonce aes sha1 sha2 hmac pem pkcs1 x509 revocation curve25519 gmp curl kernel-netlink socket-default updown vici
+}
diff --git a/testing/tests/route-based/rw-shared-vti/hosts/carol/etc/swanctl/swanctl.conf b/testing/tests/route-based/rw-shared-vti/hosts/carol/etc/swanctl/swanctl.conf
new file mode 100755 (executable)
index 0000000..15e80d2
--- /dev/null
@@ -0,0 +1,28 @@
+connections {
+
+   home {
+      local_addrs  = PH_IP_CAROL
+      remote_addrs = PH_IP_MOON
+      vips = 0.0.0.0
+
+      local {
+         auth = pubkey
+         certs = carolCert.pem
+         id = carol@strongswan.org
+      }
+      remote {
+         auth = pubkey
+         id = moon.strongswan.org
+      }
+      children {
+         home {
+            remote_ts = 10.1.0.0/16
+
+            updown = /usr/local/libexec/ipsec/_updown iptables
+            esp_proposals = aes128gcm128-x25519
+         }
+      }
+      version = 2
+      proposals = aes128-sha256-x25519
+   }
+}
diff --git a/testing/tests/route-based/rw-shared-vti/hosts/dave/etc/strongswan.conf b/testing/tests/route-based/rw-shared-vti/hosts/dave/etc/strongswan.conf
new file mode 100755 (executable)
index 0000000..ad4c18e
--- /dev/null
@@ -0,0 +1,9 @@
+# /etc/strongswan.conf - strongSwan configuration file
+
+swanctl {
+  load = pem pkcs1 x509 revocation constraints pubkey openssl random
+}
+
+charon-systemd {
+  load = random nonce aes sha1 sha2 hmac pem pkcs1 x509 revocation curve25519 gmp curl kernel-netlink socket-default updown vici
+}
diff --git a/testing/tests/route-based/rw-shared-vti/hosts/dave/etc/swanctl/swanctl.conf b/testing/tests/route-based/rw-shared-vti/hosts/dave/etc/swanctl/swanctl.conf
new file mode 100755 (executable)
index 0000000..5b14d36
--- /dev/null
@@ -0,0 +1,28 @@
+connections {
+
+   home {
+      local_addrs  = PH_IP_DAVE
+      remote_addrs = PH_IP_MOON
+      vips = 0.0.0.0
+
+      local {
+         auth = pubkey
+         certs = daveCert.pem
+         id = dave@strongswan.org
+      }
+      remote {
+         auth = pubkey
+         id = moon.strongswan.org
+      }
+      children {
+         home {
+            remote_ts = 10.1.0.0/16
+
+            updown = /usr/local/libexec/ipsec/_updown iptables
+            esp_proposals = aes128gcm128-x25519
+         }
+      }
+      version = 2
+      proposals = aes128-sha256-x25519
+   }
+}
diff --git a/testing/tests/route-based/rw-shared-vti/hosts/moon/etc/strongswan.conf b/testing/tests/route-based/rw-shared-vti/hosts/moon/etc/strongswan.conf
new file mode 100644 (file)
index 0000000..136dbe8
--- /dev/null
@@ -0,0 +1,13 @@
+# /etc/strongswan.conf - strongSwan configuration file
+
+swanctl {
+  load = pem pkcs1 x509 revocation constraints pubkey openssl random
+}
+
+charon-systemd {
+  load = random nonce aes sha1 sha2 pem pkcs1 curve25519 gmp x509 curl revocation hmac vici kernel-netlink socket-default updown
+}
+
+charon {
+  install_routes = 0
+}
diff --git a/testing/tests/route-based/rw-shared-vti/hosts/moon/etc/swanctl/swanctl.conf b/testing/tests/route-based/rw-shared-vti/hosts/moon/etc/swanctl/swanctl.conf
new file mode 100755 (executable)
index 0000000..b0efaf9
--- /dev/null
@@ -0,0 +1,33 @@
+connections {
+
+   rw {
+      local_addrs  = PH_IP_MOON
+      pools = rw_pool
+
+      local {
+         auth = pubkey
+         certs = moonCert.pem
+         id = moon.strongswan.org
+      }
+      remote {
+         auth = pubkey
+      }
+      children {
+         net {
+            local_ts  = 10.1.0.0/16
+            mark_in = 42
+            mark_out = 42
+
+            esp_proposals = aes128gcm128-x25519
+         }
+      }
+      version = 2
+      proposals = aes128-sha256-x25519
+   }
+}
+
+pools {
+    rw_pool {
+        addrs = 10.3.0.0/28
+    }
+}
diff --git a/testing/tests/route-based/rw-shared-vti/posttest.dat b/testing/tests/route-based/rw-shared-vti/posttest.dat
new file mode 100644 (file)
index 0000000..31d7564
--- /dev/null
@@ -0,0 +1,9 @@
+carol::swanctl --terminate --ike home
+dave::swanctl --terminate --ike home
+moon::systemctl stop strongswan-swanctl
+carol::systemctl stop strongswan-swanctl
+dave::systemctl stop strongswan-swanctl
+moon::iptables-restore < /etc/iptables.flush
+carol::iptables-restore < /etc/iptables.flush
+dave::iptables-restore < /etc/iptables.flush
+moon::ip tunnel del vti0
diff --git a/testing/tests/route-based/rw-shared-vti/pretest.dat b/testing/tests/route-based/rw-shared-vti/pretest.dat
new file mode 100644 (file)
index 0000000..a7afeeb
--- /dev/null
@@ -0,0 +1,17 @@
+moon::iptables-restore < /etc/iptables.rules
+carol::iptables-restore < /etc/iptables.rules
+dave::iptables-restore < /etc/iptables.rules
+moon::ip tunnel add vti0 local PH_IP_MOON remote 0.0.0.0 mode vti key 42
+moon::sysctl -w net.ipv4.conf.vti0.disable_policy=1
+moon::ip link set vti0 up
+moon::ip route add 10.3.0.0/28 dev vti0
+moon::iptables -A FORWARD -i vti0 -j ACCEPT
+moon::iptables -A FORWARD -o vti0 -j ACCEPT
+moon::systemctl start strongswan-swanctl
+carol::systemctl start strongswan-swanctl
+dave::systemctl start strongswan-swanctl
+moon::expect-connection rw
+carol::expect-connection home
+carol::swanctl --initiate --child home
+dave::expect-connection home
+dave::swanctl --initiate --child home
diff --git a/testing/tests/route-based/rw-shared-vti/test.conf b/testing/tests/route-based/rw-shared-vti/test.conf
new file mode 100644 (file)
index 0000000..1227b9d
--- /dev/null
@@ -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 moon carol winnetou dave"
+
+# Corresponding block diagram
+#
+DIAGRAM="a-m-c-w-d.png"
+
+# Guest instances on which tcpdump is to be started
+#
+TCPDUMPHOSTS="moon"
+
+# Guest instances on which IPsec is started
+# Used for IPsec logging purposes
+#
+IPSECHOSTS="moon carol dave"
+
+# charon controlled by swanctl
+#
+SWANCTL=1