aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testing/tests/ikev2/nat-two-rw-mark-in-out/description.txt15
-rw-r--r--testing/tests/ikev2/nat-two-rw-mark-in-out/evaltest.dat16
-rwxr-xr-xtesting/tests/ikev2/nat-two-rw-mark-in-out/hosts/alice/etc/ipsec.conf25
-rw-r--r--testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/alice/etc/strongswan.conf5
-rwxr-xr-xtesting/tests/ikev2/nat-two-rw-mark-in-out/hosts/sun/etc/ipsec.conf37
-rw-r--r--testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/sun/etc/strongswan.conf5
-rwxr-xr-xtesting/tests/ikev2/nat-two-rw-mark-in-out/hosts/venus/etc/ipsec.conf25
-rw-r--r--testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/venus/etc/strongswan.conf5
-rw-r--r--testing/tests/ikev2/nat-two-rw-mark-in-out/posttest.dat9
-rw-r--r--testing/tests/ikev2/nat-two-rw-mark-in-out/pretest.dat24
-rw-r--r--testing/tests/ikev2/nat-two-rw-mark-in-out/test.conf21
11 files changed, 187 insertions, 0 deletions
diff --git a/testing/tests/ikev2/nat-two-rw-mark-in-out/description.txt b/testing/tests/ikev2/nat-two-rw-mark-in-out/description.txt
new file mode 100644
index 000000000..5b5aa99f8
--- /dev/null
+++ b/testing/tests/ikev2/nat-two-rw-mark-in-out/description.txt
@@ -0,0 +1,15 @@
+The roadwarriors <b>alice</b> and <b>venus</b> sitting behind the NAT router <b>moon</b> set up
+tunnels to gateway <b>sun</b>. UDP encapsulation is used to traverse the NAT router.
+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> parameters in ipsec.conf.
+<p/>
+<b>iptables -t mangle</b> rules are then used in the PREROUTING chain to mark the traffic to
+and from <b>alice</b> and <b>venus</b>, respectively.
+<p/>
+<b>leftfirewall=yes</b> automatically inserts iptables-based firewall rules that let pass
+the tunneled traffic. In order to test the tunnel, the NAT-ed hosts <b>alice</b> and <b>venus</b>
+ping the client <b>bob</b> behind the gateway <b>sun</b>.
diff --git a/testing/tests/ikev2/nat-two-rw-mark-in-out/evaltest.dat b/testing/tests/ikev2/nat-two-rw-mark-in-out/evaltest.dat
new file mode 100644
index 000000000..74ba178d9
--- /dev/null
+++ b/testing/tests/ikev2/nat-two-rw-mark-in-out/evaltest.dat
@@ -0,0 +1,16 @@
+alice::ipsec statusall::nat-t.*INSTALLED::YES
+venus::ipsec statusall::nat-t.*INSTALLED::YES
+sun::ipsec statusall::alice.*ESTABLISHED.*alice@strongswan.org::YES
+sun::ipsec statusall::venus.*ESTABLISHED.*venus.strongswan.org::YES
+sun::ipsec statusall::alice.*10.2.0.0/16 === 10.1.0.0/25::YES
+sun::ipsec statusall::venus.*10.2.0.0/16 === 10.1.0.0/25::YES
+alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_seq=1::YES
+venus::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_seq=1::YES
+moon::tcpdump::IP moon.strongswan.org.4510.* > sun.strongswan.org.ipsec-nat-t: UDP::YES
+moon::tcpdump::IP moon.strongswan.org.4520.* > sun.strongswan.org.ipsec-nat-t: UDP::YES
+moon::tcpdump::IP sun.strongswan.org.ipsec-nat-t > moon.strongswan.org.4510.*: UDP::YES
+moon::tcpdump::IP sun.strongswan.org.ipsec-nat-t > moon.strongswan.org.4520.*: UDP::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
diff --git a/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/alice/etc/ipsec.conf b/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/alice/etc/ipsec.conf
new file mode 100755
index 000000000..0f7c23845
--- /dev/null
+++ b/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/alice/etc/ipsec.conf
@@ -0,0 +1,25 @@
+# /etc/ipsec.conf - strongSwan IPsec configuration file
+
+config setup
+ crlcheckinterval=180
+ strictcrlpolicy=no
+ plutostart=no
+
+conn %default
+ ikelifetime=60m
+ keylife=20m
+ rekeymargin=3m
+ keyingtries=1
+ keyexchange=ikev2
+
+conn nat-t
+ left=%defaultroute
+ leftsubnet=10.1.0.0/25
+ leftcert=aliceCert.pem
+ leftid=alice@strongswan.org
+ leftfirewall=yes
+ lefthostaccess=yes
+ right=PH_IP_SUN
+ rightid=@sun.strongswan.org
+ rightsubnet=10.2.0.0/16
+ auto=add
diff --git a/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/alice/etc/strongswan.conf b/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/alice/etc/strongswan.conf
new file mode 100644
index 000000000..de9ae45cc
--- /dev/null
+++ b/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/alice/etc/strongswan.conf
@@ -0,0 +1,5 @@
+# /etc/strongswan.conf - strongSwan configuration file
+
+charon {
+ load = curl aes des sha1 sha2 md5 pem pkcs1 gmp random x509 hmac xcbc stroke kernel-netlink socket-default updown
+}
diff --git a/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/sun/etc/ipsec.conf b/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/sun/etc/ipsec.conf
new file mode 100755
index 000000000..850c55f6d
--- /dev/null
+++ b/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/sun/etc/ipsec.conf
@@ -0,0 +1,37 @@
+# /etc/ipsec.conf - strongSwan IPsec configuration file
+
+config setup
+ crlcheckinterval=180
+ strictcrlpolicy=no
+ plutostart=no
+ charondebug="knl 2"
+
+conn %default
+ ikelifetime=60m
+ keylife=20m
+ rekeymargin=3m
+ keyingtries=1
+ keyexchange=ikev2
+
+conn alice
+ rightid=alice@strongswan.org
+ mark_in=10/0xffffffff
+ mark_out=11/0xffffffff
+ also=sun
+ auto=add
+
+conn venus
+ rightid=@venus.strongswan.org
+ mark_in=20 #0xffffffff is used by default
+ mark_out=21 #0xffffffff is used by default
+ also=sun
+ auto=add
+
+conn sun
+ left=PH_IP_SUN
+ leftcert=sunCert.pem
+ leftid=@sun.strongswan.org
+ leftsubnet=10.2.0.0/16
+ leftfirewall=yes
+ right=%any
+ rightsubnet=0.0.0.0/0
diff --git a/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/sun/etc/strongswan.conf b/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/sun/etc/strongswan.conf
new file mode 100644
index 000000000..de9ae45cc
--- /dev/null
+++ b/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/sun/etc/strongswan.conf
@@ -0,0 +1,5 @@
+# /etc/strongswan.conf - strongSwan configuration file
+
+charon {
+ load = curl aes des sha1 sha2 md5 pem pkcs1 gmp random x509 hmac xcbc stroke kernel-netlink socket-default updown
+}
diff --git a/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/venus/etc/ipsec.conf b/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/venus/etc/ipsec.conf
new file mode 100755
index 000000000..c82c3e978
--- /dev/null
+++ b/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/venus/etc/ipsec.conf
@@ -0,0 +1,25 @@
+# /etc/ipsec.conf - strongSwan IPsec configuration file
+
+config setup
+ crlcheckinterval=180
+ strictcrlpolicy=no
+ plutostart=no
+
+conn %default
+ ikelifetime=60m
+ keylife=20m
+ rekeymargin=3m
+ keyingtries=1
+ keyexchange=ikev2
+
+conn nat-t
+ left=%defaultroute
+ leftsubnet=10.1.0.0/25
+ leftcert=venusCert.pem
+ leftid=@venus.strongswan.org
+ leftfirewall=yes
+ lefthostaccess=yes
+ right=PH_IP_SUN
+ rightid=@sun.strongswan.org
+ rightsubnet=10.2.0.0/16
+ auto=add
diff --git a/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/venus/etc/strongswan.conf b/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/venus/etc/strongswan.conf
new file mode 100644
index 000000000..de9ae45cc
--- /dev/null
+++ b/testing/tests/ikev2/nat-two-rw-mark-in-out/hosts/venus/etc/strongswan.conf
@@ -0,0 +1,5 @@
+# /etc/strongswan.conf - strongSwan configuration file
+
+charon {
+ load = curl aes des sha1 sha2 md5 pem pkcs1 gmp random x509 hmac xcbc stroke kernel-netlink socket-default updown
+}
diff --git a/testing/tests/ikev2/nat-two-rw-mark-in-out/posttest.dat b/testing/tests/ikev2/nat-two-rw-mark-in-out/posttest.dat
new file mode 100644
index 000000000..df49eb777
--- /dev/null
+++ b/testing/tests/ikev2/nat-two-rw-mark-in-out/posttest.dat
@@ -0,0 +1,9 @@
+sun::ipsec stop
+alice::ipsec stop
+venus::ipsec stop
+alice::/etc/init.d/iptables stop 2> /dev/null
+venus::/etc/init.d/iptables stop 2> /dev/null
+sun::/etc/init.d/iptables stop 2> /dev/null
+moon::iptables -t nat -F
+moon::conntrack -F
+sun::conntrack -F
diff --git a/testing/tests/ikev2/nat-two-rw-mark-in-out/pretest.dat b/testing/tests/ikev2/nat-two-rw-mark-in-out/pretest.dat
new file mode 100644
index 000000000..52b87fa4e
--- /dev/null
+++ b/testing/tests/ikev2/nat-two-rw-mark-in-out/pretest.dat
@@ -0,0 +1,24 @@
+alice::/etc/init.d/iptables start 2> /dev/null
+venus::/etc/init.d/iptables start 2> /dev/null
+sun::/etc/init.d/iptables start 2> /dev/null
+moon::echo 1 > /proc/sys/net/ipv4/ip_forward
+moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p tcp -j SNAT --to PH_IP_MOON
+moon::iptables -t nat -A POSTROUTING -o eth0 -s PH_IP_ALICE -p udp --sport 500 -j SNAT --to PH_IP_MOON:510
+moon::iptables -t nat -A POSTROUTING -o eth0 -s PH_IP_VENUS -p udp --sport 500 -j SNAT --to PH_IP_MOON:520
+moon::iptables -t nat -A POSTROUTING -o eth0 -s PH_IP_ALICE -p udp --sport 4500 -j SNAT --to PH_IP_MOON:4510
+moon::iptables -t nat -A POSTROUTING -o eth0 -s PH_IP_VENUS -p udp --sport 4500 -j SNAT --to PH_IP_MOON:4520
+sun::echo 1 > /proc/sys/net/ipv4/ip_forward
+sun::iptables -t mangle -A PREROUTING -s PH_IP_MOON -p udp --sport 4510 -j MARK --set-mark 10
+sun::iptables -t mangle -A PREROUTING -s PH_IP_MOON -p udp --sport 4520 -j MARK --set-mark 20
+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
+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
+alice::ipsec start
+venus::ipsec start
+sun::ipsec start
+alice::sleep 2
+alice::ipsec up nat-t
+venus::sleep 2
+venus::ipsec up nat-t
+venus::sleep 2
diff --git a/testing/tests/ikev2/nat-two-rw-mark-in-out/test.conf b/testing/tests/ikev2/nat-two-rw-mark-in-out/test.conf
new file mode 100644
index 000000000..ae3c190b8
--- /dev/null
+++ b/testing/tests/ikev2/nat-two-rw-mark-in-out/test.conf
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# This configuration file provides information on the
+# UML instances used for this test
+
+# All UML instances that are required for this test
+#
+UMLHOSTS="alice venus moon winnetou sun bob"
+
+# Corresponding block diagram
+#
+DIAGRAM="a-v-m-w-s-b.png"
+
+# UML instances on which tcpdump is to be started
+#
+TCPDUMPHOSTS="moon bob"
+
+# UML instances on which IPsec is started
+# Used for IPsec logging purposes
+#
+IPSECHOSTS="alice venus sun"