/testing/guestbin/swan-prep
west #
 # confirm that the network is alive
west #
 ping -n -c 4 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.XXX ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.XXX ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.XXX ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.XXX ms
--- 127.0.0.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time XXXX
rtt min/avg/max/mdev = 0.XXX/0.XXX/0.XXX/0.XXX ms
west #
 # make sure that clear text does not get through
west #
 iptables -A INPUT -i lo -p tcp --dport 4300  -j LOGDROP
west #
 iptables -I INPUT -m policy --dir in --pol ipsec -j ACCEPT
west #
 # confirm with a ping
west #
 ping -n -c 4 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.XXX ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.XXX ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.XXX ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.XXX ms
--- 127.0.0.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time XXXX
rtt min/avg/max/mdev = 0.XXX/0.XXX/0.XXX/0.XXX ms
west #
 ipsec setup start
west #
 # openswan only - libreswan does this in _stackmanager
west #
 echo 0 >/proc/sys/net/ipv4/conf/lo/disable_xfrm
west #
 echo 0 >/proc/sys/net/ipv4/conf/lo/disable_policy
west #
 /testing/pluto/bin/wait-until-pluto-started
west #
 ipsec auto --add loopback-02-westleft
west #
 ipsec auto --add loopback-02-westright
west #
 echo "initdone"
initdone
west #
 ipsec auto --up  loopback-02-westleft
104 "loopback-02-westleft" #1: STATE_MAIN_I1: initiate
003 "loopback-02-westleft" #1: received Vendor ID payload [Openswan (this version)  VERSION
003 "loopback-02-westleft" #1: received Vendor ID payload [Dead Peer Detection]
106 "loopback-02-westleft" #1: STATE_MAIN_I2: sent MI2, expecting MR2
108 "loopback-02-westleft" #1: STATE_MAIN_I3: sent MI3, expecting MR3
003 "loopback-02-westleft" #1: received Vendor ID payload [CAN-IKEv2]
004 "loopback-02-westleft" #1: STATE_MAIN_I4: ISAKMP SA established {auth=PRESHARED_KEY cipher=aes_128 integ=sha group=MODP2048}
117 "loopback-02-westleft" #3: STATE_QUICK_I1: initiate
004 "loopback-02-westleft" #3: STATE_QUICK_I2: sent QI2, IPsec SA established transport mode {ESP=>0xESPESP <0xESPESP xfrm=AES_128-HMAC_SHA1 NATOA=none NATD=none DPD=none}
west #
 ipsec look
west NOW
IPSEC TABLE
ROUTING TABLE
default via 192.1.2.254 dev eth1 
169.254.0.0/16 dev eth1  scope link  metric 1003 
192.0.2.0/24 via 192.1.2.23 dev eth1 
192.1.2.0/24 dev eth1  proto kernel  scope link  src 192.1.2.45 
west #
 tcpdump -i lo -n -c 2 2> /dev/null &
[X] XXXX
west #
 nc -l 127.0.0.1 4300 &
[ 00.00] device lo entered promiscuous mode
[X] XXXX
west #
 sleep 1
west #
 echo test | nc 127.0.0.1 4300
test
[2]+  Done                    nc -l 127.0.0.1 4300
west #
 # should be exacly 2
IP 127.0.0.1 > 127.0.0.1: ESP(spi=0xSPISPI,seq=0xX), length XXX
IP 127.0.0.1 > 127.0.0.1: ESP(spi=0xSPISPI,seq=0xX), length XXX
[ 00.00] device lo left promiscuous mode
[1]+  Done                    tcpdump -i lo -n -c 2 2> /dev/null
west #
 grep "IPsec SA established" /tmp/pluto.log | wc -l
2
west #
 echo done
done
west #
 ipsec look
west NOW
IPSEC TABLE
ROUTING TABLE
default via 192.1.2.254 dev eth1 
169.254.0.0/16 dev eth1  scope link  metric 1003 
192.0.2.0/24 via 192.1.2.23 dev eth1 
192.1.2.0/24 dev eth1  proto kernel  scope link  src 192.1.2.45 
west #
west #
 if [ -n "`ls /tmp/core* 2>/dev/null`" ]; then echo CORE FOUND; mv /tmp/core* OUTPUT/; fi
west #
 if [ -f /sbin/ausearch ]; then ausearch -r -m avc -ts recent ; fi

