From 3f5f0b894039c4e8de4c51fed37e2fe0a66c7af6 Mon Sep 17 00:00:00 2001 From: Andreas Steffen Date: Wed, 18 Jun 2014 14:35:59 +0200 Subject: [PATCH] Added swanctl/net2net-start scenario --- .../swanctl/net2net-start/description.txt | 6 ++++ .../tests/swanctl/net2net-start/evaltest.dat | 5 +++ .../hosts/moon/etc/strongswan.conf | 13 +++++++ .../hosts/moon/etc/swanctl/swanctl.conf | 34 +++++++++++++++++++ .../hosts/sun/etc/strongswan.conf | 13 +++++++ .../hosts/sun/etc/swanctl/swanctl.conf | 34 +++++++++++++++++++ .../tests/swanctl/net2net-start/posttest.dat | 5 +++ .../tests/swanctl/net2net-start/pretest.dat | 9 +++++ testing/tests/swanctl/net2net-start/test.conf | 21 ++++++++++++ 9 files changed, 140 insertions(+) create mode 100755 testing/tests/swanctl/net2net-start/description.txt create mode 100755 testing/tests/swanctl/net2net-start/evaltest.dat create mode 100755 testing/tests/swanctl/net2net-start/hosts/moon/etc/strongswan.conf create mode 100755 testing/tests/swanctl/net2net-start/hosts/moon/etc/swanctl/swanctl.conf create mode 100755 testing/tests/swanctl/net2net-start/hosts/sun/etc/strongswan.conf create mode 100755 testing/tests/swanctl/net2net-start/hosts/sun/etc/swanctl/swanctl.conf create mode 100755 testing/tests/swanctl/net2net-start/posttest.dat create mode 100755 testing/tests/swanctl/net2net-start/pretest.dat create mode 100755 testing/tests/swanctl/net2net-start/test.conf diff --git a/testing/tests/swanctl/net2net-start/description.txt b/testing/tests/swanctl/net2net-start/description.txt new file mode 100755 index 000000000..9c67ed605 --- /dev/null +++ b/testing/tests/swanctl/net2net-start/description.txt @@ -0,0 +1,6 @@ +A tunnel connecting the subnets behind the gateways moon and sun, +respectively, is automatically established by means of the setting +auto=start in ipsec.conf. The connection is tested by client alice +behind gateway moon pinging the client bob located behind +gateway sun. The updown script automatically inserts iptables-based +firewall rules that let pass the tunneled traffic. diff --git a/testing/tests/swanctl/net2net-start/evaltest.dat b/testing/tests/swanctl/net2net-start/evaltest.dat new file mode 100755 index 000000000..cdbecd553 --- /dev/null +++ b/testing/tests/swanctl/net2net-start/evaltest.dat @@ -0,0 +1,5 @@ +moon::swanctl --list-sas --raw 2> /dev/null::gw-gw.*version=2 state=ESTABLISHED local-host=192.168.0.1 local-id=moon.strongswan.org remote-host=192.168.0.2 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=MODP_2048.*child-sas.*net-net.*state=INSTALLED mode=TUNNEL.*ESP.*encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[10.1.0.0/16] remote-ts=\[10.2.0.0/16]::YES +sun:: swanctl --list-sas --raw 2> /dev/null::gw-gw.*version=2 state=ESTABLISHED local-host=192.168.0.2 local-id=sun.strongswan.org remote-host=192.168.0.1 remote-id=moon.strongswan.org.*encr-alg=AES_CBC encr-keysize=128 integ-alg=HMAC_SHA2_256_128 prf-alg=PRF_HMAC_SHA2_256 dh-group=MODP_2048.*child-sas.*net-net.*state=INSTALLED mode=TUNNEL.*ESP.*encr-alg=AES_GCM_16 encr-keysize=128.*local-ts=\[10.2.0.0/16] remote-ts=\[10.1.0.0/16]::YES +alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_req=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/swanctl/net2net-start/hosts/moon/etc/strongswan.conf b/testing/tests/swanctl/net2net-start/hosts/moon/etc/strongswan.conf new file mode 100755 index 000000000..75f18475c --- /dev/null +++ b/testing/tests/swanctl/net2net-start/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 { + load = sha1 sha2 md5 aes des hmac pem pkcs1 x509 revocation constraints pubkey gmp random nonce curl kernel-netlink socket-default updown vici +} + +libstrongswan { + dh_exponent_ansi_x9_42 = no +} diff --git a/testing/tests/swanctl/net2net-start/hosts/moon/etc/swanctl/swanctl.conf b/testing/tests/swanctl/net2net-start/hosts/moon/etc/swanctl/swanctl.conf new file mode 100755 index 000000000..6770f6ab7 --- /dev/null +++ b/testing/tests/swanctl/net2net-start/hosts/moon/etc/swanctl/swanctl.conf @@ -0,0 +1,34 @@ +connections { + + gw-gw { + local_addrs = 192.168.0.1 + remote_addrs = 192.168.0.2 + + local { + auth = pubkey + certs = moonCert.pem + id = moon.strongswan.org + } + remote { + auth = pubkey + id = sun.strongswan.org + } + children { + net-net { + local_ts = 10.1.0.0/16 + remote_ts = 10.2.0.0/16 + + start_action = start + updown = /usr/local/libexec/ipsec/_updown iptables + rekey_time = 10m + esp_proposals = aes128gcm128-modp2048 + } + } + + version = 2 + mobike = no + reauth_time = 60m + rekey_time = 20m + proposals = aes128-sha256-modp2048 + } +} diff --git a/testing/tests/swanctl/net2net-start/hosts/sun/etc/strongswan.conf b/testing/tests/swanctl/net2net-start/hosts/sun/etc/strongswan.conf new file mode 100755 index 000000000..75f18475c --- /dev/null +++ b/testing/tests/swanctl/net2net-start/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 { + load = sha1 sha2 md5 aes des hmac pem pkcs1 x509 revocation constraints pubkey gmp random nonce curl kernel-netlink socket-default updown vici +} + +libstrongswan { + dh_exponent_ansi_x9_42 = no +} diff --git a/testing/tests/swanctl/net2net-start/hosts/sun/etc/swanctl/swanctl.conf b/testing/tests/swanctl/net2net-start/hosts/sun/etc/swanctl/swanctl.conf new file mode 100755 index 000000000..e4c855621 --- /dev/null +++ b/testing/tests/swanctl/net2net-start/hosts/sun/etc/swanctl/swanctl.conf @@ -0,0 +1,34 @@ +connections { + + gw-gw { + local_addrs = 192.168.0.2 + remote_addrs = 192.168.0.1 + + local { + auth = pubkey + certs = sunCert.pem + id = sun.strongswan.org + } + remote { + auth = pubkey + id = moon.strongswan.org + } + children { + net-net { + local_ts = 10.2.0.0/16 + remote_ts = 10.1.0.0/16 + + start_action = none + updown = /usr/local/libexec/ipsec/_updown iptables + rekey_time = 10m + esp_proposals = aes128gcm128-modp2048 + } + } + + version = 2 + mobike = no + reauth_time = 60m + rekey_time = 20m + proposals = aes128-sha256-modp2048 + } +} diff --git a/testing/tests/swanctl/net2net-start/posttest.dat b/testing/tests/swanctl/net2net-start/posttest.dat new file mode 100755 index 000000000..30d10b555 --- /dev/null +++ b/testing/tests/swanctl/net2net-start/posttest.dat @@ -0,0 +1,5 @@ +moon::swanctl --terminate --ike gw-gw 2> /dev/null +moon::service charon stop 2> /dev/null +sun::service charon stop 2> /dev/null +moon::iptables-restore < /etc/iptables.flush +sun::iptables-restore < /etc/iptables.flush diff --git a/testing/tests/swanctl/net2net-start/pretest.dat b/testing/tests/swanctl/net2net-start/pretest.dat new file mode 100755 index 000000000..0560092c5 --- /dev/null +++ b/testing/tests/swanctl/net2net-start/pretest.dat @@ -0,0 +1,9 @@ +sun::iptables-restore < /etc/iptables.rules +moon::iptables-restore < /etc/iptables.rules +sun::service charon start 2> /dev/null +moon::service charon start 2> /dev/null +sun::swanctl --load-creds 2> /dev/null +moon::swanctl --load-creds 2> /dev/null +sun::swanctl --load-conns 2> /dev/null +moon::swanctl --load-conns 2> /dev/null +moon::sleep 1 diff --git a/testing/tests/swanctl/net2net-start/test.conf b/testing/tests/swanctl/net2net-start/test.conf new file mode 100755 index 000000000..646b8b3e6 --- /dev/null +++ b/testing/tests/swanctl/net2net-start/test.conf @@ -0,0 +1,21 @@ +#!/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"