config setup
nat_traversal=yes
virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12,%v4:!10.152.2.0/24
#contains the networks that are allowed as subnet= for the remote client. In other words, the address ranges that may live behind a NAT router through which a client connects.oe=off
protostack=netkey
conn L2TP-PSK-NAT
rightsubnet=vhost:%priv
also=L2TP-PSK-noNAT
conn L2TP-PSK-noNAT
authby=secret
pfs=no
auto=add
keyingtries=3
rekey=no
# Apple iOS doesn't send delete notify so we need dead peer detection# to detect vanishing clientsdpddelay=30
dpdtimeout=120
dpdaction=clear
# Set ikelifetime and keylife to same defaults windows hasikelifetime=8h
keylife=1h
type=transport
# Replace IP address with your local IP (private, behind NAT IP is okay as well)left=x.x.x.x
# For updated Windows 2000/XP clients,# to support old clients as well, use leftprotoport=17/%anyleftprotoport=17/1701
right=%any
rightprotoport=17/%any
#force all to be nat'ed. because of iOSforceencaps=yes
for each in /proc/sys/net/ipv4/conf/*
doecho 0 > $each/accept_redirects
echo 0 > $each/send_redirects
done
验证ipsec服务
1
sudo ipsec verify
不能出现任何错误
123456789101112
Checking your system to see if IPsec got installed and started correctly:
Version check and ipsec on-path [OK]Linux Openswan U2.6.28/K2.6.32-32-generic-pae (netkey)Checking for IPsec support in kernel [OK]NETKEY detected, testing for disabled ICMP send_redirects [OK]NETKEY detected, testing for disabled ICMP accept_redirects [OK]Checking that pluto is running [OK]Pluto listening for IKE on udp 500 [OK]Pluto listening for NAT-T on udp 4500 [OK]Checking for'ip'command[OK]Checking for'iptables'command[OK]Opportunistic Encryption Support [DISABLED]