diff options
Diffstat (limited to 'testing/tests/route-based')
43 files changed, 759 insertions, 0 deletions
diff --git a/testing/tests/route-based/net2net-gre/description.txt b/testing/tests/route-based/net2net-gre/description.txt new file mode 100644 index 000000000..422f935ad --- /dev/null +++ b/testing/tests/route-based/net2net-gre/description.txt @@ -0,0 +1,12 @@ +A connection between the subnets behind the gateways <b>moon</b> and <b>sun</b> +is set up using GRE interfaces. +<p/> +The gateways use <b>route-based forwarding</b> with <b>GRE tunnels</b>, with +firewall rules to allow traffic to pass. The IPsec traffic selector is limited +to the GRE protocol, specific routing is achieved with routes on the GRE +interfaces. The IKE daemon is configured to not install routes with +<em>charon.install_routes=0</em>, and static routes are installed for the +target subnets on the VTI interfaces. +<p/> +Client <b>alice</b> behind gateway <b>moon</b> pings client <b>bob</b> located +behind gateway <b>sun</b>. diff --git a/testing/tests/route-based/net2net-gre/evaltest.dat b/testing/tests/route-based/net2net-gre/evaltest.dat new file mode 100644 index 000000000..ba9945833 --- /dev/null +++ b/testing/tests/route-based/net2net-gre/evaltest.dat @@ -0,0 +1,5 @@ +moon:: swanctl --list-sas --ike-id 1 --raw 2> /dev/null::gw.*version=2 state=ESTABLISHED local-host=PH_IP_MOON local-port=4500 local-id=moon.strongswan.org remote-host=PH_IP_SUN remote-port=4500 remote-id=sun.strongswan.org.*child-sas.*gre.*reqid=1 state=INSTALLED mode=TRANSPORT.*ESP.*local-ts=\[PH_IP_MOON/32\[gre]] remote-ts=\[PH_IP_SUN/32\[gre]]::YES +sun:: swanctl --list-sas --ike-id 1 --raw 2> /dev/null::gw.*version=2 state=ESTABLISHED local-host=PH_IP_SUN local-port=4500 local-id=sun.strongswan.org remote-host=PH_IP_MOON remote-port=4500 remote-id=moon.strongswan.org.*child-sas.*gre.*reqid=1 state=INSTALLED mode=TRANSPORT.*ESP.*local-ts=\[PH_IP_SUN/32\[gre]] remote-ts=\[PH_IP_MOON/32\[gre]]::YES +alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_.eq=1::YES +sun::tcpdump::IP moon.strongswan.org > sun.strongswan.org: ESP::YES +sun::tcpdump::IP sun.strongswan.org > moon.strongswan.org: ESP::YES diff --git a/testing/tests/route-based/net2net-gre/hosts/moon/etc/strongswan.conf b/testing/tests/route-based/net2net-gre/hosts/moon/etc/strongswan.conf new file mode 100644 index 000000000..136dbe84f --- /dev/null +++ b/testing/tests/route-based/net2net-gre/hosts/moon/etc/strongswan.conf @@ -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/net2net-gre/hosts/moon/etc/swanctl/swanctl.conf b/testing/tests/route-based/net2net-gre/hosts/moon/etc/swanctl/swanctl.conf new file mode 100755 index 000000000..b2c3af7e6 --- /dev/null +++ b/testing/tests/route-based/net2net-gre/hosts/moon/etc/swanctl/swanctl.conf @@ -0,0 +1,29 @@ +connections { + + gw-gw { + local_addrs = PH_IP_MOON + remote_addrs = PH_IP_SUN + + local { + auth = pubkey + certs = moonCert.pem + id = moon.strongswan.org + } + remote { + auth = pubkey + id = sun.strongswan.org + } + children { + gre { + local_ts = dynamic[gre] + remote_ts = dynamic[gre] + mode = transport + + updown = /usr/local/libexec/ipsec/_updown iptables + esp_proposals = aes128gcm128-x25519 + } + } + version = 2 + proposals = aes128-sha256-x25519 + } +} diff --git a/testing/tests/route-based/net2net-gre/hosts/sun/etc/strongswan.conf b/testing/tests/route-based/net2net-gre/hosts/sun/etc/strongswan.conf new file mode 100644 index 000000000..136dbe84f --- /dev/null +++ b/testing/tests/route-based/net2net-gre/hosts/sun/etc/strongswan.conf @@ -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/net2net-gre/hosts/sun/etc/swanctl/swanctl.conf b/testing/tests/route-based/net2net-gre/hosts/sun/etc/swanctl/swanctl.conf new file mode 100755 index 000000000..d19d37311 --- /dev/null +++ b/testing/tests/route-based/net2net-gre/hosts/sun/etc/swanctl/swanctl.conf @@ -0,0 +1,29 @@ +connections { + + gw-gw { + local_addrs = PH_IP_SUN + remote_addrs = PH_IP_MOON + + local { + auth = pubkey + certs = sunCert.pem + id = sun.strongswan.org + } + remote { + auth = pubkey + id = moon.strongswan.org + } + children { + gre { + local_ts = dynamic[gre] + remote_ts = dynamic[gre] + mode = transport + + updown = /usr/local/libexec/ipsec/_updown iptables + esp_proposals = aes128gcm128-x25519 + } + } + version = 2 + proposals = aes128-sha256-x25519 + } +} diff --git a/testing/tests/route-based/net2net-gre/posttest.dat b/testing/tests/route-based/net2net-gre/posttest.dat new file mode 100644 index 000000000..4007d2c64 --- /dev/null +++ b/testing/tests/route-based/net2net-gre/posttest.dat @@ -0,0 +1,7 @@ +moon::swanctl --terminate --ike gw-gw +moon::systemctl stop strongswan-swanctl +sun::systemctl stop strongswan-swanctl +moon::iptables-restore < /etc/iptables.flush +sun::iptables-restore < /etc/iptables.flush +moon::ip tunnel del gre-moon +sun::ip tunnel del gre-sun diff --git a/testing/tests/route-based/net2net-gre/pretest.dat b/testing/tests/route-based/net2net-gre/pretest.dat new file mode 100644 index 000000000..213845221 --- /dev/null +++ b/testing/tests/route-based/net2net-gre/pretest.dat @@ -0,0 +1,17 @@ +moon::iptables-restore < /etc/iptables.rules +sun::iptables-restore < /etc/iptables.rules +moon::ip tunnel add gre-moon local PH_IP_MOON remote PH_IP_SUN mode gre key 42 +moon::ip link set gre-moon up +moon::ip route add 10.2.0.0/16 dev gre-moon +moon::iptables -A FORWARD -i gre-moon -j ACCEPT +moon::iptables -A FORWARD -o gre-moon -j ACCEPT +sun::ip tunnel add gre-sun local PH_IP_SUN remote PH_IP_MOON mode gre key 42 +sun::ip link set gre-sun up +sun::ip route add 10.1.0.0/16 dev gre-sun +sun::iptables -A FORWARD -i gre-sun -j ACCEPT +sun::iptables -A FORWARD -o gre-sun -j ACCEPT +moon::systemctl start strongswan-swanctl +sun::systemctl start strongswan-swanctl +moon::expect-connection gw-gw +sun::expect-connection gw-gw +moon::swanctl --initiate --child gre diff --git a/testing/tests/route-based/net2net-gre/test.conf b/testing/tests/route-based/net2net-gre/test.conf new file mode 100644 index 000000000..87abc763b --- /dev/null +++ b/testing/tests/route-based/net2net-gre/test.conf @@ -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 winnetou sun bob" + +# Corresponding block diagram +# +DIAGRAM="a-m-w-s-b.png" + +# Guest instances on which tcpdump is to be started +# +TCPDUMPHOSTS="sun" + +# Guest instances on which IPsec is started +# Used for IPsec logging purposes +# +IPSECHOSTS="moon sun" + +# charon controlled by swanctl +# +SWANCTL=1 diff --git a/testing/tests/route-based/net2net-vti/description.txt b/testing/tests/route-based/net2net-vti/description.txt new file mode 100644 index 000000000..fc35caf6f --- /dev/null +++ b/testing/tests/route-based/net2net-vti/description.txt @@ -0,0 +1,12 @@ +A connection between the subnets behind the gateways <b>moon</b> and <b>sun</b> +is set up using VTI interfaces. +<p/> +The gateways use <b>route-based forwarding</b> with <b>VTI tunnels</b>, with +firewall rules to allow traffic to pass. The IPsec traffic selector used is +0.0.0.0/0, however specific routing is achieved with routes on the VTI +interfaces. The IKE daemon is configured to not install routes with +<em>charon.install_routes=0</em>, and static routes are installed for the +target subnets on the VTI interfaces. +<p/> +Client <b>alice</b> behind gateway <b>moon</b> pings client <b>bob</b> located +behind gateway <b>sun</b>. diff --git a/testing/tests/route-based/net2net-vti/evaltest.dat b/testing/tests/route-based/net2net-vti/evaltest.dat new file mode 100644 index 000000000..0bf5cdb5a --- /dev/null +++ b/testing/tests/route-based/net2net-vti/evaltest.dat @@ -0,0 +1,5 @@ +moon::swanctl --list-sas --ike-id 1 --raw 2> /dev/null::gw.*version=2 state=ESTABLISHED local-host=PH_IP_MOON local-port=4500 local-id=moon.strongswan.org remote-host=PH_IP_SUN remote-port=4500 remote-id=sun.strongswan.org.*child-sas.*net.*reqid=1 state=INSTALLED mode=TUNNEL.*ESP.*local-ts=\[0.0.0.0/0] remote-ts=\[0.0.0.0/0]::YES +sun::swanctl --list-sas --ike-id 1 --raw 2> /dev/null::gw.*version=2 state=ESTABLISHED local-host=PH_IP_SUN local-port=4500 local-id=sun.strongswan.org remote-host=PH_IP_MOON remote-port=4500 remote-id=moon.strongswan.org.*child-sas.*net.*reqid=1 state=INSTALLED mode=TUNNEL.*ESP.*local-ts=\[0.0.0.0/0] remote-ts=\[0.0.0.0/0]::YES +alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_.eq=1::YES +sun::tcpdump::IP moon.strongswan.org > sun.strongswan.org: ESP::YES +sun::tcpdump::IP sun.strongswan.org > moon.strongswan.org: ESP::YES diff --git a/testing/tests/route-based/net2net-vti/hosts/moon/etc/strongswan.conf b/testing/tests/route-based/net2net-vti/hosts/moon/etc/strongswan.conf new file mode 100644 index 000000000..136dbe84f --- /dev/null +++ b/testing/tests/route-based/net2net-vti/hosts/moon/etc/strongswan.conf @@ -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/net2net-vti/hosts/moon/etc/swanctl/swanctl.conf b/testing/tests/route-based/net2net-vti/hosts/moon/etc/swanctl/swanctl.conf new file mode 100755 index 000000000..e8beec307 --- /dev/null +++ b/testing/tests/route-based/net2net-vti/hosts/moon/etc/swanctl/swanctl.conf @@ -0,0 +1,29 @@ +connections { + + gw-gw { + local_addrs = PH_IP_MOON + remote_addrs = PH_IP_SUN + + local { + auth = pubkey + certs = moonCert.pem + id = moon.strongswan.org + } + remote { + auth = pubkey + id = sun.strongswan.org + } + children { + net-net { + local_ts = 0.0.0.0/0 + remote_ts = 0.0.0.0/0 + mark_in = 42 + mark_out = 42 + + esp_proposals = aes128gcm128-x25519 + } + } + version = 2 + proposals = aes128-sha256-x25519 + } +} diff --git a/testing/tests/route-based/net2net-vti/hosts/sun/etc/strongswan.conf b/testing/tests/route-based/net2net-vti/hosts/sun/etc/strongswan.conf new file mode 100644 index 000000000..136dbe84f --- /dev/null +++ b/testing/tests/route-based/net2net-vti/hosts/sun/etc/strongswan.conf @@ -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/net2net-vti/hosts/sun/etc/swanctl/swanctl.conf b/testing/tests/route-based/net2net-vti/hosts/sun/etc/swanctl/swanctl.conf new file mode 100755 index 000000000..df213159f --- /dev/null +++ b/testing/tests/route-based/net2net-vti/hosts/sun/etc/swanctl/swanctl.conf @@ -0,0 +1,29 @@ +connections { + + gw-gw { + local_addrs = PH_IP_SUN + remote_addrs = PH_IP_MOON + + local { + auth = pubkey + certs = sunCert.pem + id = sun.strongswan.org + } + remote { + auth = pubkey + id = moon.strongswan.org + } + children { + net-net { + local_ts = 0.0.0.0/0 + remote_ts = 0.0.0.0/0 + mark_in = 1337 + mark_out = 1337 + + esp_proposals = aes128gcm128-x25519 + } + } + version = 2 + proposals = aes128-sha256-x25519 + } +} diff --git a/testing/tests/route-based/net2net-vti/posttest.dat b/testing/tests/route-based/net2net-vti/posttest.dat new file mode 100644 index 000000000..47b3dff06 --- /dev/null +++ b/testing/tests/route-based/net2net-vti/posttest.dat @@ -0,0 +1,7 @@ +moon::swanctl --terminate --ike gw-gw +moon::systemctl stop strongswan-swanctl +sun::systemctl stop strongswan-swanctl +moon::iptables-restore < /etc/iptables.flush +sun::iptables-restore < /etc/iptables.flush +moon::ip tunnel del vti-moon +sun::ip tunnel del vti-sun diff --git a/testing/tests/route-based/net2net-vti/pretest.dat b/testing/tests/route-based/net2net-vti/pretest.dat new file mode 100644 index 000000000..24b285edb --- /dev/null +++ b/testing/tests/route-based/net2net-vti/pretest.dat @@ -0,0 +1,19 @@ +moon::iptables-restore < /etc/iptables.rules +sun::iptables-restore < /etc/iptables.rules +moon::ip tunnel add vti-moon local PH_IP_MOON remote PH_IP_SUN mode vti key 42 +moon::sysctl -w net.ipv4.conf.vti-moon.disable_policy=1 +moon::ip link set vti-moon up +moon::ip route add 10.2.0.0/16 dev vti-moon +moon::iptables -A FORWARD -i vti-moon -j ACCEPT +moon::iptables -A FORWARD -o vti-moon -j ACCEPT +sun::ip tunnel add vti-sun local PH_IP_SUN remote PH_IP_MOON mode vti key 1337 +sun::sysctl -w net.ipv4.conf.vti-sun.disable_policy=1 +sun::ip link set vti-sun up +sun::ip route add 10.1.0.0/16 dev vti-sun +sun::iptables -A FORWARD -i vti-sun -j ACCEPT +sun::iptables -A FORWARD -o vti-sun -j ACCEPT +moon::systemctl start strongswan-swanctl +sun::systemctl start strongswan-swanctl +moon::expect-connection gw-gw +sun::expect-connection gw-gw +moon::swanctl --initiate --child net-net diff --git a/testing/tests/route-based/net2net-vti/test.conf b/testing/tests/route-based/net2net-vti/test.conf new file mode 100644 index 000000000..87abc763b --- /dev/null +++ b/testing/tests/route-based/net2net-vti/test.conf @@ -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 winnetou sun bob" + +# Corresponding block diagram +# +DIAGRAM="a-m-w-s-b.png" + +# Guest instances on which tcpdump is to be started +# +TCPDUMPHOSTS="sun" + +# Guest instances on which IPsec is started +# Used for IPsec logging purposes +# +IPSECHOSTS="moon sun" + +# charon controlled by swanctl +# +SWANCTL=1 diff --git a/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/description.txt b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/description.txt new file mode 100644 index 000000000..305e491f0 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/description.txt @@ -0,0 +1,11 @@ +The roadwarriors <b>carol</b> and <b>dave</b> set up an IPv6-in-IPv4 connection each to +gateway <b>moon</b>. Both <b>carol</b> and <b>dave</b> request an IPv6 <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 IPv6 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>. diff --git a/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/evaltest.dat b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/evaltest.dat new file mode 100644 index 000000000..6e427b265 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/evaltest.dat @@ -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.*local-vips=\[fec3:\:1] child-sas.*home.*reqid=1 state=INSTALLED mode=TUNNEL protocol=ESP.*local-ts=\[fec3:\:1/128] remote-ts=\[fec1:\:/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.*local-vips=\[fec3:\:2] child-sas.*home.*reqid=1 state=INSTALLED mode=TUNNEL protocol=ESP.*local-ts=\[fec3:\:2/128] remote-ts=\[fec1:\:/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.*remote-vips=\[fec3:\:1] child-sas.*net.*reqid=1 state=INSTALLED mode=TUNNEL protocol=ESP.*local-ts=\[fec1:\:/16] remote-ts=\[fec3:\:1/128]::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.*remote-vips=\[fec3:\:2] child-sas.*net.*reqid=2 state=INSTALLED mode=TUNNEL protocol=ESP.*local-ts=\[fec1:\:/16] remote-ts=\[fec3:\:2/128]::YES +carol::ping6 -c 1 ip6-alice.strongswan.org::64 bytes from ip6-alice.strongswan.org: icmp_seq=1::YES +dave:: ping6 -c 1 ip6-alice.strongswan.org::64 bytes from ip6-alice.strongswan.org: icmp_seq=1::YES +moon::tcpdump::carol.strongswan.org > moon.strongswan.org: ESP::YES +moon::tcpdump::moon.strongswan.org > carol.strongswan.org: ESP::YES +moon::tcpdump::dave.strongswan.org > moon.strongswan.org: ESP::YES +moon::tcpdump::moon.strongswan.org > dave.strongswan.org: ESP::YES diff --git a/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/carol/etc/ip6tables.rules b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/carol/etc/ip6tables.rules new file mode 100644 index 000000000..409f2e9bb --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/carol/etc/ip6tables.rules @@ -0,0 +1,20 @@ +*filter + +# default policy is DROP +-P INPUT DROP +-P OUTPUT DROP +-P FORWARD DROP + +# allow ICMPv6 neighbor-solicitations +-A INPUT -p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT +-A OUTPUT -p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT + +# allow ICMPv6 neighbor-advertisements +-A INPUT -p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT +-A OUTPUT -p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT + +# log dropped packets +-A INPUT -j LOG --log-prefix " IN: " +-A OUTPUT -j LOG --log-prefix " OUT: " + +COMMIT diff --git a/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/carol/etc/strongswan.conf b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/carol/etc/strongswan.conf new file mode 100755 index 000000000..ad4c18e43 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/carol/etc/strongswan.conf @@ -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-ip6-in-ip4/hosts/carol/etc/swanctl/swanctl.conf b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/carol/etc/swanctl/swanctl.conf new file mode 100755 index 000000000..514013ee6 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/carol/etc/swanctl/swanctl.conf @@ -0,0 +1,28 @@ +connections { + + home { + local_addrs = PH_IP_CAROL + remote_addrs = PH_IP_MOON + vips = :: + + local { + auth = pubkey + certs = carolCert.pem + id = carol@strongswan.org + } + remote { + auth = pubkey + id = moon.strongswan.org + } + children { + home { + remote_ts = fec1::/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-ip6-in-ip4/hosts/dave/etc/ip6tables.rules b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/dave/etc/ip6tables.rules new file mode 100644 index 000000000..409f2e9bb --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/dave/etc/ip6tables.rules @@ -0,0 +1,20 @@ +*filter + +# default policy is DROP +-P INPUT DROP +-P OUTPUT DROP +-P FORWARD DROP + +# allow ICMPv6 neighbor-solicitations +-A INPUT -p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT +-A OUTPUT -p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT + +# allow ICMPv6 neighbor-advertisements +-A INPUT -p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT +-A OUTPUT -p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT + +# log dropped packets +-A INPUT -j LOG --log-prefix " IN: " +-A OUTPUT -j LOG --log-prefix " OUT: " + +COMMIT diff --git a/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/dave/etc/strongswan.conf b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/dave/etc/strongswan.conf new file mode 100755 index 000000000..ad4c18e43 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/dave/etc/strongswan.conf @@ -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-ip6-in-ip4/hosts/dave/etc/swanctl/swanctl.conf b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/dave/etc/swanctl/swanctl.conf new file mode 100755 index 000000000..439310569 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/dave/etc/swanctl/swanctl.conf @@ -0,0 +1,28 @@ +connections { + + home { + local_addrs = PH_IP_DAVE + remote_addrs = PH_IP_MOON + vips = :: + + local { + auth = pubkey + certs = daveCert.pem + id = dave@strongswan.org + } + remote { + auth = pubkey + id = moon.strongswan.org + } + children { + home { + remote_ts = fec1::/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-ip6-in-ip4/hosts/moon/etc/ip6tables.rules b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/moon/etc/ip6tables.rules new file mode 100644 index 000000000..409f2e9bb --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/moon/etc/ip6tables.rules @@ -0,0 +1,20 @@ +*filter + +# default policy is DROP +-P INPUT DROP +-P OUTPUT DROP +-P FORWARD DROP + +# allow ICMPv6 neighbor-solicitations +-A INPUT -p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT +-A OUTPUT -p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT + +# allow ICMPv6 neighbor-advertisements +-A INPUT -p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT +-A OUTPUT -p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT + +# log dropped packets +-A INPUT -j LOG --log-prefix " IN: " +-A OUTPUT -j LOG --log-prefix " OUT: " + +COMMIT diff --git a/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/moon/etc/strongswan.conf b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/moon/etc/strongswan.conf new file mode 100644 index 000000000..136dbe84f --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/moon/etc/strongswan.conf @@ -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-ip6-in-ip4/hosts/moon/etc/swanctl/swanctl.conf b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/moon/etc/swanctl/swanctl.conf new file mode 100755 index 000000000..c4d236aa6 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/hosts/moon/etc/swanctl/swanctl.conf @@ -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 = fec1::/16 + mark_in = 42 + mark_out = 42 + + esp_proposals = aes128gcm128-x25519 + } + } + version = 2 + proposals = aes128-sha256-x25519 + } +} + +pools { + rw_pool { + addrs = fec3::/120 + } +} diff --git a/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/posttest.dat b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/posttest.dat new file mode 100644 index 000000000..2b17600b8 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/posttest.dat @@ -0,0 +1,13 @@ +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::ip6tables-restore < /etc/iptables.flush +carol::ip6tables-restore < /etc/iptables.flush +dave::ip6tables-restore < /etc/iptables.flush +moon::ip tunnel del vti0 +alice::"ip route del fec3:\:/16 via fec1:\:1" diff --git a/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/pretest.dat b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/pretest.dat new file mode 100644 index 000000000..2380dc0f3 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/pretest.dat @@ -0,0 +1,21 @@ +moon::iptables-restore < /etc/iptables.rules +carol::iptables-restore < /etc/iptables.rules +dave::iptables-restore < /etc/iptables.rules +moon::ip6tables-restore < /etc/ip6tables.rules +carol::ip6tables-restore < /etc/ip6tables.rules +dave::ip6tables-restore < /etc/ip6tables.rules +alice::"ip route add fec3:\:/16 via fec1:\:1" +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 fec3:\:/16 dev vti0" +moon::ip6tables -A FORWARD -i vti0 -j ACCEPT +moon::ip6tables -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-ip6-in-ip4/test.conf b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/test.conf new file mode 100644 index 000000000..0f02a1a11 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti-ip6-in-ip4/test.conf @@ -0,0 +1,29 @@ +#!/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-ip6.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" + +# IP protocol used by IPsec is IPv6 +# +IPV6=1 + +# charon controlled by swanctl +# +SWANCTL=1 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 index 000000000..fa11b2df5 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti/description.txt @@ -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 index 000000000..f69310314 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti/evaltest.dat @@ -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 index 000000000..ad4c18e43 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti/hosts/carol/etc/strongswan.conf @@ -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 index 000000000..15e80d2aa --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti/hosts/carol/etc/swanctl/swanctl.conf @@ -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 index 000000000..ad4c18e43 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti/hosts/dave/etc/strongswan.conf @@ -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 index 000000000..5b14d36ef --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti/hosts/dave/etc/swanctl/swanctl.conf @@ -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 index 000000000..136dbe84f --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti/hosts/moon/etc/strongswan.conf @@ -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 index 000000000..b0efaf9c1 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti/hosts/moon/etc/swanctl/swanctl.conf @@ -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 index 000000000..31d75642a --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti/posttest.dat @@ -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 index 000000000..a7afeeb35 --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti/pretest.dat @@ -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 index 000000000..1227b9d1c --- /dev/null +++ b/testing/tests/route-based/rw-shared-vti/test.conf @@ -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 |