testing: Migrate MOBIKE tests to vici

Note that the mobike-nat test has been removed as it basically did the same
as the mobike-virtual-ip-nat test.  Instead, the mobike-nat-mapping scenario
is added, which simulates a NAT router restart.
This commit is contained in:
Tobias Brunner
2021-06-21 12:03:36 +02:00
committed by Andreas Steffen
parent abe51389c5
commit 2b5c743952
65 changed files with 404 additions and 332 deletions
@@ -0,0 +1,6 @@
The roadwarrior <b>alice</b> is sitting behind the NAT router <b>moon</b>.
<b>alice</b> builds up a tunnel to gateway <b>sun</b> in order to reach <b>bob</b>
in the subnet behind. When the NAT router <b>moon</b> is restarted, the NAT
mappings change. <b>alice</b> notices this when sending a DPD and signals the
change via a MOBIKE ADDRESS_UPDATE notification to peer <b>sun</b>. <b>alice</b> sets
a virtual IP of 10.3.0.3, so that the IPsec policies don't have to be changed.
@@ -0,0 +1,27 @@
alice::swanctl --list-sas --raw 2> /dev/null::mobike.*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.*protocol=ESP encap=yes spi-in.*local-ts=\[10.3.0.3/32] remote-ts=\[10.2.0.0/16]::YES
sun:: swanctl --list-sas --raw 2> /dev/null::mobike.*state=ESTABLISHED local-host=PH_IP_SUN local-port=4500 local-id=sun.strongswan.org remote-host=PH_IP_MOON remote-port=1... [email protected].*protocol=ESP encap=yes spi-in.*local-ts=\[10.2.0.0/16] remote-ts=\[10.3.0.3/32]::YES
alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_.eq=1::YES
bob:: ping -c 1 10.3.0.3::64 bytes from 10.3.0.3: icmp_.eq=1::YES
# wait until one DPD has been exchanged, as we can't detect changed NAT mappings
# with the NAT-D payloads from IKE_SA_INIT as we changed the ports with IKE_AUTH
alice::sleep 6::No output expected::NO
# simulate a restart of the NAT router, bob won't be able to ping
moon::iptables -t nat -F
moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p udp -j SNAT --to-source PH_IP_MOON:5000-5100
moon::conntrack -F
bob::ping -c 1 -W 1 10.3.0.3::64 bytes from 10.3.0.3: icmp_.eq=1::NO
# wait until the next DPD detects the changed NAT mapping and updates the endpoints
alice::sleep 6::No output expected::NO
alice::cat /var/log/daemon.log::sending DPD request::YES
alice::cat /var/log/daemon.log::detected changes in NAT mappings, initiating MOBIKE update::YES
sun:: cat /var/log/daemon.log::remote endpoint changed from PH_IP_MOON\[1...] to PH_IP_MOON\[5...]::YES
alice::swanctl --list-sas --raw 2> /dev/null::mobike.*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.*protocol=ESP encap=yes spi-in.*local-ts=\[10.3.0.3/32] remote-ts=\[10.2.0.0/16]::YES
sun:: swanctl --list-sas --raw 2> /dev/null::mobike.*state=ESTABLISHED local-host=PH_IP_SUN local-port=4500 local-id=sun.strongswan.org remote-host=PH_IP_MOON remote-port=5... [email protected].*protocol=ESP encap=yes spi-in.*local-ts=\[10.2.0.0/16] remote-ts=\[10.3.0.3/32]::YES
alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_.eq=1::YES
bob:: ping -c 1 10.3.0.3::64 bytes from 10.3.0.3: icmp_.eq=1::YES
moon::tcpdump::moon.strongswan.org.*sun.strongswan.org.*: UDP-encap: ESP.*::4
moon::tcpdump::sun.strongswan.org.*moon.strongswan.org.*: UDP-encap: ESP.*::5
bob::tcpdump::10.3.0.3.*bob.strongswan.org.*ICMP echo request::2
bob::tcpdump::bob.strongswan.org.*10.3.0.3.*ICMP echo reply::2
bob::tcpdump::bob.strongswan.org.*10.3.0.3.*ICMP echo request::3
bob::tcpdump::10.3.0.3.*bob.strongswan.org.*ICMP echo reply::2
@@ -0,0 +1,36 @@
*filter
# default policy is DROP
-P INPUT DROP
-P OUTPUT DROP
-P FORWARD DROP
# allow traffic on lo as ifup/ifdown call bind's rndc which accesses TCP 953
-A OUTPUT -o lo -j ACCEPT
-A INPUT -i lo -j ACCEPT
# allow IPsec tunnel traffic
-A INPUT -m policy --dir in --pol ipsec --proto esp -j ACCEPT
-A OUTPUT -m policy --dir out --pol ipsec --proto esp -j ACCEPT
# allow ESP
-A INPUT -i eth0 -p 50 -j ACCEPT
-A OUTPUT -o eth0 -p 50 -j ACCEPT
# allow IKE
-A INPUT -i eth0 -p udp --sport 500 --dport 500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
# allow MobIKE
-A INPUT -i eth0 -p udp --sport 4500 --dport 4500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --dport 4500 --sport 4500 -j ACCEPT
# allow ssh
-A INPUT -p tcp --dport 22 -j ACCEPT
-A OUTPUT -p tcp --sport 22 -j ACCEPT
# allow crl fetch from winnetou
-A INPUT -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
-A OUTPUT -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
COMMIT
@@ -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 sha1 sha2 aes hmac pem pkcs1 x509 revocation constraints pubkey curve25519 gmp curl kernel-netlink socket-default resolve updown vici
}
@@ -0,0 +1,25 @@
connections {
mobike {
remote_addrs = PH_IP_SUN
vips = 0.0.0.0
dpd_delay = 5
local {
auth = pubkey
certs = aliceCert.pem
id = [email protected]
}
remote {
auth = pubkey
id = sun.strongswan.org
}
children {
mobike {
remote_ts = 10.2.0.0/16
}
}
}
}
@@ -0,0 +1,32 @@
*filter
# default policy is DROP
-P INPUT DROP
-P OUTPUT DROP
-P FORWARD DROP
# allow IPsec tunnel traffic
-A FORWARD -m policy --dir in --pol ipsec --proto esp -j ACCEPT
-A FORWARD -m policy --dir out --pol ipsec --proto esp -j ACCEPT
# allow ESP
-A INPUT -i eth0 -p 50 -j ACCEPT
-A OUTPUT -o eth0 -p 50 -j ACCEPT
# allow IKE
-A INPUT -i eth0 -p udp --dport 500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --sport 500 -j ACCEPT
# allow MobIKE
-A INPUT -i eth0 -p udp --dport 4500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --sport 4500 -j ACCEPT
# allow ssh
-A INPUT -p tcp --dport 22 -j ACCEPT
-A OUTPUT -p tcp --sport 22 -j ACCEPT
# allow crl fetch from winnetou
-A INPUT -i eth0 -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
-A OUTPUT -o eth0 -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
COMMIT
@@ -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 sha1 sha2 aes hmac pem pkcs1 x509 revocation constraints pubkey curve25519 gmp curl kernel-netlink socket-default resolve updown vici
}
@@ -0,0 +1,29 @@
connections {
mobike {
local_addrs = PH_IP_SUN
pools = mobike
local {
auth = pubkey
certs = sunCert.pem
id = sun.strongswan.org
}
remote {
auth = pubkey
id = [email protected]
}
children {
mobike {
local_ts = 10.2.0.0/16
}
}
}
}
pools {
mobike {
addrs = 10.3.0.3/32
}
}
@@ -0,0 +1,5 @@
alice::systemctl stop strongswan
sun::systemctl stop strongswan
alice::iptables-restore < /etc/iptables.flush
sun::iptables-restore < /etc/iptables.flush
moon::iptables -t nat -F
@@ -0,0 +1,9 @@
alice::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p udp -j SNAT --to-source PH_IP_MOON:1024-1100
moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p tcp -j SNAT --to-source PH_IP_MOON:2000-2100
alice::systemctl start strongswan
sun::systemctl start strongswan
alice::expect-connection mobike
sun::expect-connection mobike
alice::swanctl --initiate --child mobike 2> /dev/null
@@ -0,0 +1,24 @@
#!/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="bob moon sun"
# Guest instances on which IPsec is started
# Used for IPsec logging purposes
#
IPSECHOSTS="alice sun"
# charon controlled by swanctl
SWANCTL=1
@@ -0,0 +1,9 @@
The roadwarrior <b>alice</b> is sitting behind the NAT router <b>moon</b> but
at the outset of the scenario is also directly connected to the 192.168.0.0/24 network
via an additional <b>eth1</b> interface. <b>alice</b> builds up a tunnel to gateway <b>sun</b>
in order to reach <b>bob</b> in the subnet behind. When the <b>eth1</b> interface
goes away, <b>alice</b> switches to <b>eth0</b> and signals the IP address change
via a MOBIKE ADDRESS_UPDATE notification to peer <b>sun</b>. Later the interface
comes back up again and because the best path is preferred (charon-systemd.prefer_best_path)
there is another switch to the directly connected path. <b>alice</b> sets
a virtual IP of 10.3.0.3, so that the IPsec policies don't have to be changed.
@@ -0,0 +1,19 @@
alice::swanctl --list-sas --raw 2> /dev/null::mobike.*state=ESTABLISHED local-host=192.168.0.50 local-port=4500 [email protected] remote-host=PH_IP_SUN remote-port=4500 remote-id=sun.strongswan.org.*protocol=ESP spi-in.*local-ts=\[10.3.0.3/32] remote-ts=\[10.2.0.0/16]::YES
sun:: swanctl --list-sas --raw 2> /dev/null::mobike.*state=ESTABLISHED local-host=PH_IP_SUN local-port=4500 local-id=sun.strongswan.org remote-host=192.168.0.50 remote-port=4500 [email protected].*protocol=ESP spi-in.*local-ts=\[10.2.0.0/16] remote-ts=\[10.3.0.3/32]::YES
alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_.eq=1::YES
alice::ifdown eth1::No output expected::NO
alice::sleep 1::No output expected::NO
alice::swanctl --list-sas --raw 2> /dev/null::mobike.*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.*protocol=ESP encap=yes spi-in.*local-ts=\[10.3.0.3/32] remote-ts=\[10.2.0.0/16]::YES
sun:: swanctl --list-sas --raw 2> /dev/null::mobike.*state=ESTABLISHED local-host=PH_IP_SUN local-port=4500 local-id=sun.strongswan.org remote-host=PH_IP_MOON remote-port=1... [email protected].*protocol=ESP encap=yes spi-in.*local-ts=\[10.2.0.0/16] remote-ts=\[10.3.0.3/32]::YES
alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_.eq=1::YES
alice::ifup eth1::No output expected::NO
alice::sleep 1::No output expected::NO
alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_.eq=1::YES
alice::swanctl --list-sas --raw 2> /dev/null::mobike.*state=ESTABLISHED local-host=192.168.0.50 local-port=4500 [email protected] remote-host=PH_IP_SUN remote-port=4500 remote-id=sun.strongswan.org.*protocol=ESP spi-in.*local-ts=\[10.3.0.3/32] remote-ts=\[10.2.0.0/16]::YES
sun:: swanctl --list-sas --raw 2> /dev/null::mobike.*state=ESTABLISHED local-host=PH_IP_SUN local-port=4500 local-id=sun.strongswan.org remote-host=192.168.0.50 remote-port=4500 [email protected].*protocol=ESP spi-in.*local-ts=\[10.2.0.0/16] remote-ts=\[10.3.0.3/32]::YES
sun::tcpdump::alice1.strongswan.org.*sun.strongswan.org: ESP.*seq=0x1::YES
sun::tcpdump::sun.strongswan.org.*alice1.strongswan.org: ESP.*seq=0x1::YES
moon::tcpdump::moon.strongswan.org.*sun.strongswan.org.*: ESP.*seq=0x2::YES
moon::tcpdump::sun.strongswan.org.*moon.strongswan.org.*: ESP.*seq=0x2::YES
bob::tcpdump::10.3.0.3.*bob.strongswan.org.*ICMP echo request::3
bob::tcpdump::bob.strongswan.org.*10.3.0.3.*ICMP echo reply::3
@@ -0,0 +1,42 @@
*filter
# default policy is DROP
-P INPUT DROP
-P OUTPUT DROP
-P FORWARD DROP
# allow traffic on lo as ifup/ifdown call bind's rndc which accesses TCP 953
-A OUTPUT -o lo -j ACCEPT
-A INPUT -i lo -j ACCEPT
# allow IPsec tunnel traffic
-A INPUT -m policy --dir in --pol ipsec --proto esp -j ACCEPT
-A OUTPUT -m policy --dir out --pol ipsec --proto esp -j ACCEPT
# allow ESP
-A INPUT -i eth0 -p 50 -j ACCEPT
-A INPUT -i eth1 -p 50 -j ACCEPT
-A OUTPUT -o eth0 -p 50 -j ACCEPT
-A OUTPUT -o eth1 -p 50 -j ACCEPT
# allow IKE
-A INPUT -i eth0 -p udp --sport 500 --dport 500 -j ACCEPT
-A INPUT -i eth1 -p udp --sport 500 --dport 500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
-A OUTPUT -o eth1 -p udp --dport 500 --sport 500 -j ACCEPT
# allow MobIKE
-A INPUT -i eth0 -p udp --sport 4500 --dport 4500 -j ACCEPT
-A INPUT -i eth1 -p udp --sport 4500 --dport 4500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --dport 4500 --sport 4500 -j ACCEPT
-A OUTPUT -o eth1 -p udp --dport 4500 --sport 4500 -j ACCEPT
# allow ssh
-A INPUT -p tcp --dport 22 -j ACCEPT
-A OUTPUT -p tcp --sport 22 -j ACCEPT
# allow crl fetch from winnetou
-A INPUT -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
-A OUTPUT -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
COMMIT
@@ -0,0 +1,16 @@
# /etc/strongswan.conf - strongSwan configuration file
swanctl {
load = pem pkcs1 x509 revocation constraints pubkey openssl random
}
charon-systemd {
load = random nonce sha1 sha2 aes hmac pem pkcs1 x509 revocation constraints pubkey curve25519 gmp curl kernel-netlink socket-default resolve updown vici
prefer_best_path = yes
syslog {
daemon {
knl = 2
}
}
}
@@ -0,0 +1,23 @@
connections {
mobike {
remote_addrs = PH_IP_SUN
vips = 0.0.0.0
local {
auth = pubkey
certs = aliceCert.pem
id = [email protected]
}
remote {
auth = pubkey
id = sun.strongswan.org
}
children {
mobike {
remote_ts = 10.2.0.0/16
}
}
}
}
@@ -0,0 +1,32 @@
*filter
# default policy is DROP
-P INPUT DROP
-P OUTPUT DROP
-P FORWARD DROP
# allow IPsec tunnel traffic
-A FORWARD -m policy --dir in --pol ipsec --proto esp -j ACCEPT
-A FORWARD -m policy --dir out --pol ipsec --proto esp -j ACCEPT
# allow ESP
-A INPUT -i eth0 -p 50 -j ACCEPT
-A OUTPUT -o eth0 -p 50 -j ACCEPT
# allow IKE
-A INPUT -i eth0 -p udp --dport 500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --sport 500 -j ACCEPT
# allow MobIKE
-A INPUT -i eth0 -p udp --dport 4500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --sport 4500 -j ACCEPT
# allow ssh
-A INPUT -p tcp --dport 22 -j ACCEPT
-A OUTPUT -p tcp --sport 22 -j ACCEPT
# allow crl fetch from winnetou
-A INPUT -i eth0 -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
-A OUTPUT -o eth0 -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
COMMIT
@@ -0,0 +1,15 @@
# /etc/strongswan.conf - strongSwan configuration file
swanctl {
load = pem pkcs1 x509 revocation constraints pubkey openssl random
}
charon-systemd {
load = random nonce sha1 sha2 aes hmac pem pkcs1 x509 revocation constraints pubkey curve25519 gmp curl kernel-netlink socket-default resolve updown vici
syslog {
daemon {
knl = 2
}
}
}
@@ -0,0 +1,29 @@
connections {
mobike {
local_addrs = PH_IP_SUN
pools = mobike
local {
auth = pubkey
certs = sunCert.pem
id = sun.strongswan.org
}
remote {
auth = pubkey
id = [email protected]
}
children {
mobike {
local_ts = 10.2.0.0/16
}
}
}
}
pools {
mobike {
addrs = 10.3.0.3/32
}
}
@@ -0,0 +1,6 @@
alice::systemctl stop strongswan
sun::systemctl stop strongswan
alice::ifdown eth1
alice::iptables-restore < /etc/iptables.flush
sun::iptables-restore < /etc/iptables.flush
moon::iptables -t nat -F
@@ -0,0 +1,10 @@
alice::ifup eth1
alice::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p udp -j SNAT --to-source PH_IP_MOON:1024-1100
moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p tcp -j SNAT --to-source PH_IP_MOON:2000-2100
alice::systemctl start strongswan
sun::systemctl start strongswan
alice::expect-connection mobike
sun::expect-connection mobike
alice::swanctl --initiate --child mobike 2> /dev/null
@@ -0,0 +1,24 @@
#!/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="bob moon sun"
# Guest instances on which IPsec is started
# Used for IPsec logging purposes
#
IPSECHOSTS="alice sun"
# charon controlled by swanctl
SWANCTL=1
@@ -0,0 +1,7 @@
The roadwarrior <b>alice</b> is sitting behind the router <b>moon</b> but
at the outset of the scenario is also directly connected to the 192.168.0.0/24 network
via an additional <b>eth1</b> interface. <b>alice</b> builds up a tunnel to gateway <b>sun</b>
in order to reach <b>bob</b> in the subnet behind. When the <b>eth1</b> interface
goes away, <b>alice</b> switches to <b>eth0</b> and signals the IP address change
via a MOBIKE ADDRESS_UPDATE notification to peer <b>sun</b>. <b>alice</b> sets
a virtual IP of 10.3.0.3, so that the IPsec policies don't have to be changed.
@@ -0,0 +1,14 @@
alice::swanctl --list-sas --raw 2> /dev/null::mobike.*state=ESTABLISHED local-host=192.168.0.50 local-port=4500 [email protected] remote-host=PH_IP_SUN remote-port=4500 remote-id=sun.strongswan.org.*local-ts=\[10.3.0.3/32] remote-ts=\[10.2.0.0/16]::YES
sun:: swanctl --list-sas --raw 2> /dev/null::mobike.*state=ESTABLISHED local-host=PH_IP_SUN local-port=4500 local-id=sun.strongswan.org remote-host=192.168.0.50 remote-port=4500 [email protected].*local-ts=\[10.2.0.0/16] remote-ts=\[10.3.0.3/32]::YES
alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_.eq=1::YES
alice::ifdown eth1::No output expected::NO
alice::sleep 1::No output expected::NO
alice::swanctl --list-sas --raw 2> /dev/null::mobike.*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.*local-ts=\[10.3.0.3/32] remote-ts=\[10.2.0.0/16]::YES
sun:: swanctl --list-sas --raw 2> /dev/null::mobike.*state=ESTABLISHED local-host=PH_IP_SUN local-port=4500 local-id=sun.strongswan.org remote-host=PH_IP_ALICE remote-port=4500 [email protected].*local-ts=\[10.2.0.0/16] remote-ts=\[10.3.0.3/32]::YES
alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_.eq=1::YES
sun::tcpdump::alice1.strongswan.org.*sun.strongswan.org: ESP.*seq=0x1::YES
sun::tcpdump::sun.strongswan.org.*alice1.strongswan.org: ESP.*seq=0x1::YES
moon::tcpdump::alice.strongswan.org.*sun.strongswan.org.*: ESP.*seq=0x2::YES
moon::tcpdump::sun.strongswan.org.*alice.strongswan.org.*: ESP.*seq=0x2::YES
bob::tcpdump::10.3.0.3.*bob.strongswan.org.*ICMP echo request::2
bob::tcpdump::bob.strongswan.org.*10.3.0.3.*ICMP echo reply::2
@@ -0,0 +1,42 @@
*filter
# default policy is DROP
-P INPUT DROP
-P OUTPUT DROP
-P FORWARD DROP
# allow traffic on lo as ifup/ifdown call bind's rndc which accesses TCP 953
-A OUTPUT -o lo -j ACCEPT
-A INPUT -i lo -j ACCEPT
# allow IPsec tunnel traffic
-A INPUT -m policy --dir in --pol ipsec --proto esp -j ACCEPT
-A OUTPUT -m policy --dir out --pol ipsec --proto esp -j ACCEPT
# allow ESP
-A INPUT -i eth0 -p 50 -j ACCEPT
-A INPUT -i eth1 -p 50 -j ACCEPT
-A OUTPUT -o eth0 -p 50 -j ACCEPT
-A OUTPUT -o eth1 -p 50 -j ACCEPT
# allow IKE
-A INPUT -i eth0 -p udp --sport 500 --dport 500 -j ACCEPT
-A INPUT -i eth1 -p udp --sport 500 --dport 500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
-A OUTPUT -o eth1 -p udp --dport 500 --sport 500 -j ACCEPT
# allow MobIKE
-A INPUT -i eth0 -p udp --sport 4500 --dport 4500 -j ACCEPT
-A INPUT -i eth1 -p udp --sport 4500 --dport 4500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --dport 4500 --sport 4500 -j ACCEPT
-A OUTPUT -o eth1 -p udp --dport 4500 --sport 4500 -j ACCEPT
# allow ssh
-A INPUT -p tcp --dport 22 -j ACCEPT
-A OUTPUT -p tcp --sport 22 -j ACCEPT
# allow crl fetch from winnetou
-A INPUT -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
-A OUTPUT -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
COMMIT
@@ -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 sha1 sha2 aes hmac pem pkcs1 x509 revocation constraints pubkey curve25519 gmp curl kernel-netlink socket-default resolve updown vici
}
@@ -0,0 +1,24 @@
connections {
mobike {
local_addrs = 192.168.0.50
remote_addrs = PH_IP_SUN
vips = 0.0.0.0
local {
auth = pubkey
certs = aliceCert.pem
id = [email protected]
}
remote {
auth = pubkey
id = sun.strongswan.org
}
children {
mobike {
remote_ts = 10.2.0.0/16
}
}
}
}
@@ -0,0 +1,32 @@
*filter
# default policy is DROP
-P INPUT DROP
-P OUTPUT DROP
-P FORWARD DROP
# allow IPsec tunnel traffic
-A FORWARD -m policy --dir in --pol ipsec --proto esp -j ACCEPT
-A FORWARD -m policy --dir out --pol ipsec --proto esp -j ACCEPT
# allow ESP
-A INPUT -i eth0 -p 50 -j ACCEPT
-A OUTPUT -o eth0 -p 50 -j ACCEPT
# allow IKE
-A INPUT -i eth0 -p udp --sport 500 --dport 500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
# allow MobIKE
-A INPUT -i eth0 -p udp --sport 4500 --dport 4500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --dport 4500 --sport 4500 -j ACCEPT
# allow ssh
-A INPUT -p tcp --dport 22 -j ACCEPT
-A OUTPUT -p tcp --sport 22 -j ACCEPT
# allow crl fetch from winnetou
-A INPUT -i eth0 -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
-A OUTPUT -o eth0 -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
COMMIT
@@ -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 sha1 sha2 aes hmac pem pkcs1 x509 revocation constraints pubkey curve25519 gmp curl kernel-netlink socket-default resolve updown vici
}
@@ -0,0 +1,30 @@
connections {
mobike {
local_addrs = PH_IP_SUN
remote_addrs = 192.168.0.50
pools = mobike
local {
auth = pubkey
certs = sunCert.pem
id = sun.strongswan.org
}
remote {
auth = pubkey
id = [email protected]
}
children {
mobike {
local_ts = 10.2.0.0/16
}
}
}
}
pools {
mobike {
addrs = 10.3.0.3/32
}
}
@@ -0,0 +1,5 @@
alice::systemctl stop strongswan
sun::systemctl stop strongswan
alice::iptables-restore < /etc/iptables.flush
sun::iptables-restore < /etc/iptables.flush
sun::ip route del 10.1.0.0/16 via PH_IP_MOON
@@ -0,0 +1,9 @@
alice::ifup eth1
alice::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
sun::ip route add 10.1.0.0/16 via PH_IP_MOON
alice::systemctl start strongswan
sun::systemctl start strongswan
alice::expect-connection mobike
sun::expect-connection mobike
alice::swanctl --initiate --child mobike 2> /dev/null
@@ -0,0 +1,24 @@
#!/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="bob moon sun"
# Guest instances on which IPsec is started
# Used for IPsec logging purposes
#
IPSECHOSTS="alice sun"
# charon controlled by swanctl
SWANCTL=1
@@ -0,0 +1,7 @@
The roadwarrior <b>alice</b> is sitting behind the router <b>moon</b> but
at the outset of the scenario is also directly connected to the 192.168.0.0/24 network
via an additional <b>eth1</b> interface. <b>alice</b> builds up a tunnel to gateway <b>sun</b>
in order to reach <b>bob</b> in the subnet behind. When the <b>eth1</b> interface
goes away, <b>alice</b> switches to <b>eth0</b> and signals the IP address change
via a MOBIKE ADDRESS_UPDATE notification to peer <b>sun</b>. Since <b>alice</b> has
not configured a virtual IP address the IPsec policies must be updated.
+16
View File
@@ -0,0 +1,16 @@
alice::swanctl --list-sas --raw 2> /dev/null::mobike.*state=ESTABLISHED local-host=192.168.0.50 local-port=4500 [email protected] remote-host=PH_IP_SUN remote-port=4500 remote-id=sun.strongswan.org.*local-ts=\[192.168.0.50/32] remote-ts=\[10.2.0.0/16]::YES
sun:: swanctl --list-sas --raw 2> /dev/null::mobike.*state=ESTABLISHED local-host=PH_IP_SUN local-port=4500 local-id=sun.strongswan.org remote-host=192.168.0.50 remote-port=4500 [email protected].*local-ts=\[10.2.0.0/16] remote-ts=\[192.168.0.50/32]::YES
alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_.eq=1::YES
alice::ifdown eth1::No output expected::NO
alice::sleep 1::No output expected::NO
alice::swanctl --list-sas --raw 2> /dev/null::mobike.*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.*local-ts=\[PH_IP_ALICE/32] remote-ts=\[10.2.0.0/16]::YES
sun:: swanctl --list-sas --raw 2> /dev/null::mobike.*state=ESTABLISHED local-host=PH_IP_SUN local-port=4500 local-id=sun.strongswan.org remote-host=PH_IP_ALICE remote-port=4500 [email protected].*local-ts=\[10.2.0.0/16] remote-ts=\[PH_IP_ALICE/32]::YES
alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_.eq=1::YES
sun::tcpdump::alice1.strongswan.org.*sun.strongswan.org: ESP.*seq=0x1::YES
sun::tcpdump::sun.strongswan.org.*alice1.strongswan.org: ESP.*seq=0x1::YES
moon::tcpdump::alice.strongswan.org.*sun.strongswan.org: ESP.*seq=0x2::YES
moon::tcpdump::sun.strongswan.org.*alice.strongswan.org: ESP.*seq=0x2::YES
bob::tcpdump::alice1.strongswan.org.*bob.strongswan.org.*ICMP echo request::YES
bob::tcpdump::bob.strongswan.org.*alice1.strongswan.org.*ICMP echo reply::YES
bob::tcpdump::alice.strongswan.org.*bob.strongswan.org.*ICMP echo request::YES
bob::tcpdump::bob.strongswan.org.*alice.strongswan.org.*ICMP echo reply::YES
@@ -0,0 +1,42 @@
*filter
# default policy is DROP
-P INPUT DROP
-P OUTPUT DROP
-P FORWARD DROP
# allow traffic on lo as ifup/ifdown call bind's rndc which accesses TCP 953
-A OUTPUT -o lo -j ACCEPT
-A INPUT -i lo -j ACCEPT
# allow IPsec tunnel traffic
-A INPUT -m policy --dir in --pol ipsec --proto esp -j ACCEPT
-A OUTPUT -m policy --dir out --pol ipsec --proto esp -j ACCEPT
# allow ESP
-A INPUT -i eth0 -p 50 -j ACCEPT
-A INPUT -i eth1 -p 50 -j ACCEPT
-A OUTPUT -o eth0 -p 50 -j ACCEPT
-A OUTPUT -o eth1 -p 50 -j ACCEPT
# allow IKE
-A INPUT -i eth0 -p udp --sport 500 --dport 500 -j ACCEPT
-A INPUT -i eth1 -p udp --sport 500 --dport 500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
-A OUTPUT -o eth1 -p udp --dport 500 --sport 500 -j ACCEPT
# allow MobIKE
-A INPUT -i eth0 -p udp --sport 4500 --dport 4500 -j ACCEPT
-A INPUT -i eth1 -p udp --sport 4500 --dport 4500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --dport 4500 --sport 4500 -j ACCEPT
-A OUTPUT -o eth1 -p udp --dport 4500 --sport 4500 -j ACCEPT
# allow ssh
-A INPUT -p tcp --dport 22 -j ACCEPT
-A OUTPUT -p tcp --sport 22 -j ACCEPT
# allow crl fetch from winnetou
-A INPUT -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
-A OUTPUT -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
COMMIT
@@ -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 sha1 sha2 aes hmac pem pkcs1 x509 revocation constraints pubkey curve25519 gmp curl kernel-netlink socket-default resolve updown vici
}
@@ -0,0 +1,22 @@
connections {
mobike {
local_addrs = 192.168.0.50
remote_addrs = PH_IP_SUN
local {
auth = pubkey
certs = aliceCert.pem
id = [email protected]
}
remote {
auth = pubkey
id = sun.strongswan.org
}
children {
mobike {
remote_ts = 10.2.0.0/16
}
}
}
}
@@ -0,0 +1,32 @@
*filter
# default policy is DROP
-P INPUT DROP
-P OUTPUT DROP
-P FORWARD DROP
# allow IPsec tunnel traffic
-A FORWARD -m policy --dir in --pol ipsec --proto esp -j ACCEPT
-A FORWARD -m policy --dir out --pol ipsec --proto esp -j ACCEPT
# allow ESP
-A INPUT -i eth0 -p 50 -j ACCEPT
-A OUTPUT -o eth0 -p 50 -j ACCEPT
# allow IKE
-A INPUT -i eth0 -p udp --sport 500 --dport 500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
# allow MobIKE
-A INPUT -i eth0 -p udp --sport 4500 --dport 4500 -j ACCEPT
-A OUTPUT -o eth0 -p udp --dport 4500 --sport 4500 -j ACCEPT
# allow ssh
-A INPUT -p tcp --dport 22 -j ACCEPT
-A OUTPUT -p tcp --sport 22 -j ACCEPT
# allow crl fetch from winnetou
-A INPUT -i eth0 -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
-A OUTPUT -o eth0 -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
COMMIT
@@ -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 sha1 sha2 aes hmac pem pkcs1 x509 revocation constraints pubkey curve25519 gmp curl kernel-netlink socket-default resolve updown vici
}
@@ -0,0 +1,22 @@
connections {
mobike {
local_addrs = PH_IP_SUN
remote_addrs = 192.168.0.50
local {
auth = pubkey
certs = sunCert.pem
id = sun.strongswan.org
}
remote {
auth = pubkey
id = [email protected]
}
children {
mobike {
local_ts = 10.2.0.0/16
}
}
}
}
+5
View File
@@ -0,0 +1,5 @@
alice::systemctl stop strongswan
sun::systemctl stop strongswan
alice::iptables-restore < /etc/iptables.flush
sun::iptables-restore < /etc/iptables.flush
sun::ip route del 10.1.0.0/16 via PH_IP_MOON
+9
View File
@@ -0,0 +1,9 @@
alice::ifup eth1
alice::iptables-restore < /etc/iptables.rules
sun::iptables-restore < /etc/iptables.rules
sun::ip route add 10.1.0.0/16 via PH_IP_MOON
alice::systemctl start strongswan
sun::systemctl start strongswan
alice::expect-connection mobike
sun::expect-connection mobike
alice::swanctl --initiate --child mobike 2> /dev/null
+24
View File
@@ -0,0 +1,24 @@
#!/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="bob moon sun"
# Guest instances on which IPsec is started
# Used for IPsec logging purposes
#
IPSECHOSTS="alice sun"
# charon controlled by swanctl
SWANCTL=1