added p2pnat/medsrv-psk scenario
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
The peers <b>alice</b> and <b>bob</b> are hidden behind the NAT routers <b>moon</b> and <b>sun</b>,
|
||||
respectively. Due to this double-NAT situation they cannot set up an IPsec tunnel directly
|
||||
but need the assistance from the mediation server <b>carol</b> with which they register under
|
||||
the pseudonyms <b>[email protected]</b> and <b>[email protected]</b>, respectively,
|
||||
authenticating by means of individual pre-shared keys. Using the set of endpoints relayed
|
||||
to them by the mediation server, the peers are able to set up a direct IPsec connection..
|
||||
In order to test the double NAT-ed IPsec tunnel both peers ping each other.
|
||||
@@ -0,0 +1,12 @@
|
||||
alice::ipsec statusall::medsrv.*ESTABLISHED::YES
|
||||
bob::ipsec statusall::medsrv.*ESTABLISHED::YES
|
||||
carol::ipsec statusall::medsrv.*ESTABLISHED.*PH_IP_MOON.*[email protected]::YES
|
||||
carol::ipsec statusall::medsrv.*ESTABLISHED.*PH_IP_SUN.*[email protected]::YES
|
||||
alice::ipsec statusall::p2p.*ESTABLISHED::YES
|
||||
bob::ipsec statusall::p2p.*ESTABLISHED::YES
|
||||
alice::ipsec statusall::p2p.*INSTALLED::YES
|
||||
bob::ipsec statusall::p2p.*INSTALLED::YES
|
||||
alice::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_seq=1::YES
|
||||
bob::ping -c 1 PH_IP_ALICE::64 bytes from PH_IP_ALICE: icmp_seq=1::YES
|
||||
moon::tcpdump::IP moon.strongswan.org.* > sun.strongswan.org.*: UDP::YES
|
||||
moon::tcpdump::IP sun.strongswan.org.* > moon.strongswan.org.*: UDP::YES
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/sbin/runscript
|
||||
# Copyright 1999-2004 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
opts="start stop reload"
|
||||
|
||||
depend() {
|
||||
before net
|
||||
need logger
|
||||
}
|
||||
|
||||
start() {
|
||||
ebegin "Starting firewall"
|
||||
|
||||
# default policy is DROP
|
||||
/sbin/iptables -P INPUT DROP
|
||||
/sbin/iptables -P OUTPUT DROP
|
||||
/sbin/iptables -P FORWARD DROP
|
||||
|
||||
# allow IKE
|
||||
iptables -A INPUT -i eth0 -p udp --sport 500 --dport 500 -j ACCEPT
|
||||
iptables -A OUTPUT -o eth0 -p udp --dport 500 --sport 500 -j ACCEPT
|
||||
|
||||
# allow NAT-T including P2P
|
||||
iptables -A INPUT -i eth0 -p udp --dport 4500 -j ACCEPT
|
||||
iptables -A OUTPUT -o eth0 -p udp --sport 4500 -j ACCEPT
|
||||
|
||||
|
||||
# allow crl fetch from winnetou
|
||||
iptables -A INPUT -i eth0 -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
|
||||
iptables -A OUTPUT -o eth0 -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
|
||||
|
||||
# allow ssh
|
||||
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
|
||||
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
|
||||
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Stopping firewall"
|
||||
for a in `cat /proc/net/ip_tables_names`; do
|
||||
/sbin/iptables -F -t $a
|
||||
/sbin/iptables -X -t $a
|
||||
|
||||
if [ $a == nat ]; then
|
||||
/sbin/iptables -t nat -P PREROUTING ACCEPT
|
||||
/sbin/iptables -t nat -P POSTROUTING ACCEPT
|
||||
/sbin/iptables -t nat -P OUTPUT ACCEPT
|
||||
elif [ $a == mangle ]; then
|
||||
/sbin/iptables -t mangle -P PREROUTING ACCEPT
|
||||
/sbin/iptables -t mangle -P INPUT ACCEPT
|
||||
/sbin/iptables -t mangle -P FORWARD ACCEPT
|
||||
/sbin/iptables -t mangle -P OUTPUT ACCEPT
|
||||
/sbin/iptables -t mangle -P POSTROUTING ACCEPT
|
||||
elif [ $a == filter ]; then
|
||||
/sbin/iptables -t filter -P INPUT ACCEPT
|
||||
/sbin/iptables -t filter -P FORWARD ACCEPT
|
||||
/sbin/iptables -t filter -P OUTPUT ACCEPT
|
||||
fi
|
||||
done
|
||||
eend $?
|
||||
}
|
||||
|
||||
reload() {
|
||||
ebegin "Flushing firewall"
|
||||
for a in `cat /proc/net/ip_tables_names`; do
|
||||
/sbin/iptables -F -t $a
|
||||
/sbin/iptables -X -t $a
|
||||
done;
|
||||
eend $?
|
||||
start
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# /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
|
||||
mobike=no
|
||||
dpdaction=restart
|
||||
dpddelay=60s
|
||||
left=%defaultroute
|
||||
leftfirewall=yes
|
||||
|
||||
conn medsrv
|
||||
[email protected]
|
||||
right=PH_IP_CAROL
|
||||
[email protected]
|
||||
p2p_mediation=yes
|
||||
authby=psk
|
||||
auto=add
|
||||
|
||||
conn p2p
|
||||
leftcert=aliceCert.pem
|
||||
[email protected]
|
||||
right=%any
|
||||
[email protected]
|
||||
rightsubnet=PH_IP_BOB/32
|
||||
p2p_mediated_by=medsrv
|
||||
[email protected]
|
||||
auto=start
|
||||
@@ -0,0 +1,7 @@
|
||||
# /etc/ipsec.secrets - strongSwan IPsec secrets file
|
||||
|
||||
: RSA aliceKey.pem
|
||||
|
||||
# secret used for mediation connection
|
||||
|
||||
[email protected] : PSK "BAXz/6cSITttd0CzF9799p859Pi4LPnP"
|
||||
@@ -0,0 +1,36 @@
|
||||
# /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
|
||||
mobike=no
|
||||
dpdaction=restart
|
||||
dpddelay=60s
|
||||
left=%defaultroute
|
||||
leftfirewall=yes
|
||||
|
||||
conn medsrv
|
||||
[email protected]
|
||||
right=PH_IP_CAROL
|
||||
[email protected]
|
||||
authby=psk
|
||||
p2p_mediation=yes
|
||||
auto=add
|
||||
|
||||
conn p2p
|
||||
leftcert=bobCert.pem
|
||||
[email protected]
|
||||
right=%any
|
||||
[email protected]
|
||||
rightsubnet=PH_IP_ALICE/32
|
||||
p2p_mediated_by=medsrv
|
||||
[email protected]
|
||||
auto=start
|
||||
@@ -0,0 +1,7 @@
|
||||
# /etc/ipsec.secrets - strongSwan IPsec secrets file
|
||||
|
||||
: RSA bobKey.pem
|
||||
|
||||
# secret used for mediation connection
|
||||
|
||||
[email protected] : PSK "ZVm3FLOiweS1ywUDpR/L9FvpwNYp9svt"
|
||||
@@ -0,0 +1,77 @@
|
||||
#!/sbin/runscript
|
||||
# Copyright 1999-2004 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
opts="start stop reload"
|
||||
|
||||
depend() {
|
||||
before net
|
||||
need logger
|
||||
}
|
||||
|
||||
start() {
|
||||
ebegin "Starting firewall"
|
||||
|
||||
# default policy is DROP
|
||||
/sbin/iptables -P INPUT DROP
|
||||
/sbin/iptables -P OUTPUT DROP
|
||||
/sbin/iptables -P FORWARD DROP
|
||||
|
||||
# allow esp
|
||||
iptables -A INPUT -i eth0 -p 50 -j ACCEPT
|
||||
iptables -A OUTPUT -o eth0 -p 50 -j ACCEPT
|
||||
|
||||
# allow IKE behind NAT
|
||||
iptables -A INPUT -i eth0 -p udp --dport 500 -j ACCEPT
|
||||
iptables -A OUTPUT -o eth0 -p udp --sport 500 -j ACCEPT
|
||||
|
||||
# allow NAT-T
|
||||
iptables -A INPUT -i eth0 -p udp --dport 4500 -j ACCEPT
|
||||
iptables -A OUTPUT -o eth0 -p udp --sport 4500 -j ACCEPT
|
||||
|
||||
# allow crl fetch from winnetou
|
||||
iptables -A INPUT -i eth0 -p tcp --sport 80 -s PH_IP_WINNETOU -j ACCEPT
|
||||
iptables -A OUTPUT -o eth0 -p tcp --dport 80 -d PH_IP_WINNETOU -j ACCEPT
|
||||
|
||||
# allow ssh
|
||||
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
|
||||
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
|
||||
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Stopping firewall"
|
||||
for a in `cat /proc/net/ip_tables_names`; do
|
||||
/sbin/iptables -F -t $a
|
||||
/sbin/iptables -X -t $a
|
||||
|
||||
if [ $a == nat ]; then
|
||||
/sbin/iptables -t nat -P PREROUTING ACCEPT
|
||||
/sbin/iptables -t nat -P POSTROUTING ACCEPT
|
||||
/sbin/iptables -t nat -P OUTPUT ACCEPT
|
||||
elif [ $a == mangle ]; then
|
||||
/sbin/iptables -t mangle -P PREROUTING ACCEPT
|
||||
/sbin/iptables -t mangle -P INPUT ACCEPT
|
||||
/sbin/iptables -t mangle -P FORWARD ACCEPT
|
||||
/sbin/iptables -t mangle -P OUTPUT ACCEPT
|
||||
/sbin/iptables -t mangle -P POSTROUTING ACCEPT
|
||||
elif [ $a == filter ]; then
|
||||
/sbin/iptables -t filter -P INPUT ACCEPT
|
||||
/sbin/iptables -t filter -P FORWARD ACCEPT
|
||||
/sbin/iptables -t filter -P OUTPUT ACCEPT
|
||||
fi
|
||||
done
|
||||
eend $?
|
||||
}
|
||||
|
||||
reload() {
|
||||
ebegin "Flushing firewall"
|
||||
for a in `cat /proc/net/ip_tables_names`; do
|
||||
/sbin/iptables -F -t $a
|
||||
/sbin/iptables -X -t $a
|
||||
done;
|
||||
eend $?
|
||||
start
|
||||
}
|
||||
|
||||
@@ -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
|
||||
mobike=no
|
||||
dpdaction=clear
|
||||
dpddelay=60s
|
||||
|
||||
conn medsrv
|
||||
left=PH_IP_CAROL
|
||||
leftcert=carolCert.pem
|
||||
[email protected]
|
||||
leftfirewall=yes
|
||||
right=%any
|
||||
p2p_mediation=yes
|
||||
auto=add
|
||||
@@ -0,0 +1,9 @@
|
||||
# /etc/ipsec.secrets - strongSwan IPsec secrets file
|
||||
|
||||
: RSA carolKey.pem "nH5ZQEWtku0RJEZ6"
|
||||
|
||||
# Mediation clients with random IDs
|
||||
|
||||
[email protected] : PSK "BAXz/6cSITttd0CzF9799p859Pi4LPnP"
|
||||
|
||||
[email protected] : PSK "ZVm3FLOiweS1ywUDpR/L9FvpwNYp9svt"
|
||||
@@ -0,0 +1,10 @@
|
||||
bob::ipsec stop
|
||||
alice::ipsec stop
|
||||
carol::ipsec stop
|
||||
alice::/etc/init.d/iptables stop 2> /dev/null
|
||||
moon::/etc/init.d/iptables stop 2> /dev/null
|
||||
carol::/etc/init.d/iptables stop 2> /dev/null
|
||||
sun::/etc/init.d/iptables stop 2> /dev/null
|
||||
bob::/etc/init.d/iptables stop 2> /dev/null
|
||||
moon::conntrack -F
|
||||
sun::conntrack -F
|
||||
@@ -0,0 +1,21 @@
|
||||
alice::/etc/init.d/iptables start 2> /dev/null
|
||||
moon::/etc/init.d/iptables start 2> /dev/null
|
||||
carol::/etc/init.d/iptables start 2> /dev/null
|
||||
sun::/etc/init.d/iptables start 2> /dev/null
|
||||
bob::/etc/init.d/iptables start 2> /dev/null
|
||||
moon::conntrack -F
|
||||
moon::iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p udp -j SNAT --to-source PH_IP_MOON:1100-1200
|
||||
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
|
||||
moon::iptables -A FORWARD -i eth1 -o eth0 -s 10.1.0.0/16 -j ACCEPT
|
||||
moon::iptables -A FORWARD -i eth0 -o eth1 -d 10.1.0.0/16 -j ACCEPT
|
||||
sun::conntrack -F
|
||||
sun::iptables -t nat -A POSTROUTING -o eth0 -s 10.2.0.0/16 -p udp -j SNAT --to-source PH_IP_SUN:1200-1300
|
||||
sun::iptables -t nat -A POSTROUTING -o eth0 -s 10.2.0.0/16 -p tcp -j SNAT --to-source PH_IP_SUN:2000-2100
|
||||
sun::iptables -A FORWARD -i eth1 -o eth0 -s 10.2.0.0/16 -j ACCEPT
|
||||
sun::iptables -A FORWARD -i eth0 -o eth1 -d 10.2.0.0/16 -j ACCEPT
|
||||
carol::ipsec start
|
||||
carol::sleep 1
|
||||
alice::ipsec start
|
||||
alice::sleep 1
|
||||
bob::ipsec start
|
||||
bob::sleep 10
|
||||
@@ -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 moon carol winnetou sun bob"
|
||||
|
||||
# Corresponding block diagram
|
||||
#
|
||||
DIAGRAM="a-m-c-w-s-b-med.png"
|
||||
|
||||
# UML instances on which tcpdump is to be started
|
||||
#
|
||||
TCPDUMPHOSTS="moon"
|
||||
|
||||
# UML instances on which IPsec is started
|
||||
# Used for IPsec logging purposes
|
||||
#
|
||||
IPSECHOSTS="alice carol bob"
|
||||
Reference in New Issue
Block a user