mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-04 00:00:14 -04:00
added
This commit is contained in:
parent
e6cfe0eecc
commit
a9ae2c01ed
6
testing/tests/ikev1/nat-before-esp/description.txt
Normal file
6
testing/tests/ikev1/nat-before-esp/description.txt
Normal file
@ -0,0 +1,6 @@
|
||||
An IPsec tunnel connecting the gateway <b>moon</b> with the subnet behind
|
||||
gateway <b>sun</b> is set up. This host-to-net connection can also be
|
||||
used by the clients <b>alice</b> and <b>venus</b> via the trick of NAT-ing
|
||||
them to the outer IP address of gateway <b>moon</b> prior to tunnelling.
|
||||
The IPsec tunnel is first tested by <b>moon</b> pinging <b>bob</b> and vice versa,
|
||||
followed by the NAT-ed clients <b>alice</b> and <b>venus</b> pinging <b>bob</b>.
|
9
testing/tests/ikev1/nat-before-esp/evaltest.dat
Normal file
9
testing/tests/ikev1/nat-before-esp/evaltest.dat
Normal file
@ -0,0 +1,9 @@
|
||||
moon::ipsec status::host-net.*STATE_QUICK_I2.*IPsec SA established::YES
|
||||
sun::ipsec status::host-net.*STATE_QUICK_R2.*IPsec SA established::YES
|
||||
moon::ping -c 1 PH_IP_BOB::64 bytes from PH_IP_BOB: icmp_seq=1::YES
|
||||
bob::ping -c 1 PH_IP_MOON::64 bytes from PH_IP_MOON: icmp_seq=1::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
|
||||
sun::tcpdump::IP moon.strongswan.org > sun.strongswan.org: ESP::YES
|
||||
sun::tcpdump::IP sun.strongswan.org > moon.strongswan.org: ESP::YES
|
||||
bob::tcpdump::icmp::YES
|
83
testing/tests/ikev1/nat-before-esp/hosts/moon/etc/init.d/iptables
Executable file
83
testing/tests/ikev1/nat-before-esp/hosts/moon/etc/init.d/iptables
Executable file
@ -0,0 +1,83 @@
|
||||
#!/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"
|
||||
|
||||
# enable IP forwarding
|
||||
echo 1 > /proc/sys/net/ipv4/ip_forward
|
||||
|
||||
# default policy is DROP
|
||||
/sbin/iptables -P INPUT DROP
|
||||
/sbin/iptables -P OUTPUT DROP
|
||||
/sbin/iptables -P FORWARD DROP
|
||||
|
||||
# NAT traffic from 10.1.0.0/16
|
||||
iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -j MASQUERADE
|
||||
|
||||
# forward traffic from 10.1.0.0/16 to POSTROUTING chain
|
||||
iptables -A FORWARD -i eth1 -o eth0 -s 10.1.0.0/16 -d 10.2.0.0/16 -j ACCEPT
|
||||
iptables -A FORWARD -o eth1 -i eth0 -d 10.1.0.0/16 -s 10.2.0.0/16 -j ACCEPT
|
||||
|
||||
# allow esp
|
||||
iptables -A INPUT -i eth0 -p 50 -j ACCEPT
|
||||
iptables -A OUTPUT -o eth0 -p 50 -j ACCEPT
|
||||
|
||||
# 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 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
|
||||
}
|
||||
|
24
testing/tests/ikev1/nat-before-esp/hosts/moon/etc/ipsec.conf
Executable file
24
testing/tests/ikev1/nat-before-esp/hosts/moon/etc/ipsec.conf
Executable file
@ -0,0 +1,24 @@
|
||||
# /etc/ipsec.conf - strongSwan IPsec configuration file
|
||||
|
||||
config setup
|
||||
plutodebug=control
|
||||
crlcheckinterval=180
|
||||
strictcrlpolicy=no
|
||||
charonstart=no
|
||||
|
||||
conn %default
|
||||
ikelifetime=60m
|
||||
keylife=20m
|
||||
rekeymargin=3m
|
||||
keyingtries=1
|
||||
|
||||
conn host-net
|
||||
left=192.168.0.1
|
||||
leftnexthop=%direct
|
||||
leftcert=moonCert.pem
|
||||
leftid=@moon.strongswan.org
|
||||
leftfirewall=yes
|
||||
right=192.168.0.2
|
||||
rightsubnet=10.2.0.0/16
|
||||
rightid=@sun.strongswan.org
|
||||
auto=add
|
23
testing/tests/ikev1/nat-before-esp/hosts/sun/etc/ipsec.conf
Executable file
23
testing/tests/ikev1/nat-before-esp/hosts/sun/etc/ipsec.conf
Executable file
@ -0,0 +1,23 @@
|
||||
# /etc/ipsec.conf - strongSwan IPsec configuration file
|
||||
|
||||
config setup
|
||||
plutodebug=control
|
||||
crlcheckinterval=180
|
||||
strictcrlpolicy=no
|
||||
nat_traversal=yes
|
||||
charonstart=no
|
||||
|
||||
conn %default
|
||||
ikelifetime=60m
|
||||
keylife=20m
|
||||
rekeymargin=3m
|
||||
keyingtries=1
|
||||
|
||||
conn host-net
|
||||
left=192.168.0.2
|
||||
leftcert=sunCert.pem
|
||||
leftid=@sun.strongswan.org
|
||||
leftfirewall=yes
|
||||
leftsubnet=10.2.0.0/16
|
||||
right=%any
|
||||
auto=add
|
6
testing/tests/ikev1/nat-before-esp/posttest.dat
Normal file
6
testing/tests/ikev1/nat-before-esp/posttest.dat
Normal file
@ -0,0 +1,6 @@
|
||||
moon::iptables -v -n -L
|
||||
moon::iptables -t nat -v -n -L
|
||||
moon::ipsec stop
|
||||
sun::ipsec stop
|
||||
moon::/etc/init.d/iptables stop 2> /dev/null
|
||||
sun::/etc/init.d/iptables stop 2> /dev/null
|
6
testing/tests/ikev1/nat-before-esp/pretest.dat
Normal file
6
testing/tests/ikev1/nat-before-esp/pretest.dat
Normal file
@ -0,0 +1,6 @@
|
||||
moon::/etc/init.d/iptables start 2> /dev/null
|
||||
sun::/etc/init.d/iptables start 2> /dev/null
|
||||
moon::ipsec start
|
||||
sun::ipsec start
|
||||
moon::sleep 2
|
||||
moon::ipsec up host-net
|
21
testing/tests/ikev1/nat-before-esp/test.conf
Normal file
21
testing/tests/ikev1/nat-before-esp/test.conf
Normal file
@ -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-m-w-s-b.png"
|
||||
|
||||
# UML instances on which tcpdump is to be started
|
||||
#
|
||||
TCPDUMPHOSTS="sun bob"
|
||||
|
||||
# UML instances on which IPsec is started
|
||||
# Used for IPsec logging purposes
|
||||
#
|
||||
IPSECHOSTS="moon sun"
|
Loading…
x
Reference in New Issue
Block a user