TCPDUMP moon# tcpdump -i eth0 not port ssh and not port domain and not arp > /tmp/tcpdump.log 2>&1 & PRE-TEST alice# /etc/init.d/iptables start 2> /dev/null * Caching service dependencies ... [ ok ] * Starting firewall ... [ ok ] bob# /etc/init.d/iptables start 2> /dev/null * Caching service dependencies ... [ ok ] * Starting firewall ... [ ok ] moon# echo 1 > /proc/sys/net/ipv4/ip_forward sun# echo 1 > /proc/sys/net/ipv4/ip_forward moon# iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p udp -j SNAT --to-source 192.168.0.1:1024-1100 moon# iptables -t nat -A POSTROUTING -o eth0 -s 10.1.0.0/16 -p tcp -j SNAT --to-source 192.168.0.1:2000-2100 sun# iptables -t nat -A POSTROUTING -o eth0 -s 10.2.0.0/16 -p tcp -j SNAT --to-source 192.168.0.2:2000-2100 sun# iptables -t nat -A PREROUTING -i eth0 -s 192.168.0.1 -p udp -j DNAT --to-destination 10.2.0.10 alice# ipsec start Starting strongSwan 4.2.10 IPsec [starter]... bob# ipsec start Starting strongSwan 4.2.10 IPsec [starter]... alice# sleep 3 alice# ipsec up nat-t initiating IKE_SA nat-t[1] to 192.168.0.2 generating IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) ] sending packet: from 10.1.0.10[500] to 192.168.0.2[500] received packet: from 192.168.0.2[500] to 10.1.0.10[500] parsed IKE_SA_INIT response 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) CERTREQ ] local host is behind NAT, sending keep alives remote host is behind NAT received cert request for "C=CH, O=Linux strongSwan, CN=strongSwan Root CA" sending cert request for "C=CH, O=Linux strongSwan, CN=strongSwan Root CA" authentication of 'alice@strongswan.org' (myself) with RSA signature successful sending end entity cert "C=CH, O=Linux strongSwan, OU=Sales, CN=alice@strongswan.org" establishing CHILD_SA nat-t generating IKE_AUTH request 1 [ IDi CERT CERTREQ IDr AUTH SA TSi TSr N(MOBIKE_SUP) N(ADD_6_ADDR) ] sending packet: from 10.1.0.10[4500] to 192.168.0.2[4500] received packet: from 192.168.0.2[4500] to 10.1.0.10[4500] parsed IKE_AUTH response 1 [ IDr CERT AUTH SA TSi TSr N(AUTH_LFT) N(MOBIKE_SUP) N(ADD_6_ADDR) ] received end entity cert "C=CH, O=Linux strongSwan, OU=Research, CN=bob@strongswan.org" using certificate "C=CH, O=Linux strongSwan, OU=Research, CN=bob@strongswan.org" using trusted ca certificate "C=CH, O=Linux strongSwan, CN=strongSwan Root CA" checking certificate status of "C=CH, O=Linux strongSwan, OU=Research, CN=bob@strongswan.org" fetching crl from 'http://crl.strongswan.org/strongswan.crl' ... using trusted certificate "C=CH, O=Linux strongSwan, CN=strongSwan Root CA" crl correctly signed by "C=CH, O=Linux strongSwan, CN=strongSwan Root CA" crl is valid: until Jan 25 08:45:40 2009 certificate status is good authentication of 'bob@strongswan.org' with RSA signature successful scheduling reauthentication in 3250s maximum IKE_SA lifetime 3430s IKE_SA nat-t[1] established between 10.1.0.10[alice@strongswan.org]...192.168.0.2[bob@strongswan.org] alice# sleep 1 TEST alice# ipsec statusall | grep 'nat-t.*INSTALLED' [YES] nat-t{1}: INSTALLED, TUNNEL, ESP in UDP SPIs: ced18913_i c2762ae3_o bob# ipsec statusall | grep 'nat-t.*INSTALLED' [YES] nat-t{1}: INSTALLED, TUNNEL, ESP in UDP SPIs: c2762ae3_i ced18913_o alice# ping -c 1 10.2.0.10 | grep '64 bytes from 10.2.0.10: icmp_seq=1' [YES] 64 bytes from 10.2.0.10: icmp_seq=1 ttl=64 time=0.732 ms moon# killall tcpdump moon# cat /tmp/tcpdump.log | grep 'IP moon.strongswan.org.* > sun.strongswan.org.ipsec-nat-t: UDP' [YES] 10:41:50.545343 IP moon.strongswan.org.1026 > sun.strongswan.org.ipsec-nat-t: UDP-encap: ESP(spi=0xc2762ae3,seq=0x1), length 132 moon# cat /tmp/tcpdump.log | grep 'IP sun.strongswan.org.ipsec-nat-t > moon.strongswan.org.*: UDP' [YES] 10:41:50.545790 IP sun.strongswan.org.ipsec-nat-t > moon.strongswan.org.1026: UDP-encap: ESP(spi=0xced18913,seq=0x1), length 132 POST-TEST bob# ipsec stop Stopping strongSwan IPsec... alice# ipsec stop Stopping strongSwan IPsec... alice# /etc/init.d/iptables stop 2> /dev/null * Stopping firewall ... [ ok ] bob# /etc/init.d/iptables stop 2> /dev/null * Stopping firewall ... [ ok ] moon# iptables -t nat -F sun# iptables -t nat -F moon# conntrack -F sun# conntrack -F