ipsec
Cento安装L2TP/IPSec VPN
yum install -y ppp gmp xl2tpd lsof
32位
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
wget http://openswan.org/download/binaries/centos/5/without-nss/openswan-2.6.24rc5-1.i386.rpm
rpm -ivh openswan-2.6.24rc5-1.i386.rpm
64位
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm
wget http://openswan.org/download/binaries/centos/5/without-nss/openswan-2.6.24rc5-1.x86_64.rpm
rpm -ivh openswan-2.6.24rc5-1.x86_64.rpm
vi /etc/sysctl.conf
修改
net.ipv4.ip_forward = 1
添加
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
sysctl -p
service ipsec start
ipsec verify查看
除了最后一个,其他均需要OK
Checking your system to see if IPsec got installed and started correctly:
Version check and ipsec on-path [OK]
Linux Openswan U2.6.24rc5/K2.6.18-164.11.1.el5xen (netkey)
Checking for IPsec support in kernel [OK]
Testing against enforced SElinux mode [OK]
NETKEY detected, testing for disabled ICMP send_redirects [OK]
NETKEY detected, testing for disabled ICMP accept_redirects [OK]
Checking for RSA private key (/etc/ipsec.secrets) [OK]
Checking that pluto is running [OK]
Pluto listening for IKE on udp 500 [OK]
Pluto listening for NAT-T on udp 4500 [OK]
Two or more interfaces found, checking IP forwarding [OK]
Checking NAT and MASQUERADEing
Checking for ‘ip’ command [OK]
Checking for ‘iptables’ command [OK]
Opportunistic Encryption Support [DISABLED]
vi /etc/ipsec.conf
version 2.0
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
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
type=transport
left=YOUR.SERVER.IP.ADDRESS
leftprotoport=17/1701
right=%any
rightprotoport=17/%any
vi /etc/ipsec.secrets
YOUR.SERVER.IP.ADDRESS %any: PSK "YourSharedSecret"
service ipsec restart
vi /etc/xl2tpd/xl2tpd.conf
[global]
listen-addr = YOUR.SERVER.IP.ADDRESS
ipsec saref = yes
[lns default]
ip range = 192.168.8.2-192.168.8.101
local ip = 192.168.8.1
;require chap = yes
refuse pap = yes
refuse chap = yes
require authentication = yes
name = l2tpd
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes
vi /etc/ppp/options.xl2tpd
require-mschap-v2
ms-dns 8.8.8.8
ms-dns 8.8.4.4
asyncmap 0
auth
crtscts
lock
hide-password
modem
debug
name l2tpd
proxyarp
vi /etc/ppp/chap-secrets
test * test *
service xl2tpd start
(xl2tpd -D 查错)
service iptables start
iptables -t nat -A POSTROUTING -s 192.168.8.0/24 -o eth0 -j MASQUERADE
service iptables save
service iptables restart
chkconfig --list
chkconfig ipsec on
chkconfig xl2tpd on
iptables -I RH-Firewall-1-INPUT 10 -p udp -m udp --dport 1701 -j ACCEPT
iptables -I RH-Firewall-1-INPUT 10 -p udp -m udp --dport 4500 -j ACCEPT
iptables -I RH-Firewall-1-INPUT 10 -p udp -m udp --dport 500 -j ACCEPT
OK!
其他的一些参考配置
1、修改/etc/xl2tpd/xl2tpd.conf,内容如下:
mkdir /etc/xl2tpd
cp examples/xl2tpd.conf /etc/xl2tpd/
vi /etc/xl2tpd/xl2tpd.conf
[global]
listen-addr = 192.168.1.67
port=1701
auth file=/etc/ppp/chap-secrets #// 有l2tp-secret auth file = /etc/xl2tpd/l2tp-secrets
[lns default]
ip range = 192.168.9.128-192.168.9.254
local ip = 192.168.9.99
require chap = yes
refuse pap = yes
require authentication = yes
name = LinuxVPNserver
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes
2、修改/etc/ppp/options.xl2tpd,内容如下:
cp examples/ppp-options.xl2tpd /etc/ppp/options.xl2tpd
vi /etc/ppp/options.xl2tpd
ipcp-accept-local
ipcp-accept-remote
ms-dns 192.168.1.1
ms-dns 192.168.1.3
ms-wins 192.168.1.2
ms-wins 192.168.1.4
noccp
auth
crtscts
idle 1800
mtu 1410
mru 1410
nodefaultroute
debug
lock
proxyarp
connect-delay 5000
iphone 设置L2TP/IPSec VPN
首先,打开“设置”—-“通用”—-“网络”—-“VPN”—-“添加VPN配置”,在协议类型上选择“L2TP”,在“描述Description”栏中填入“vpn”,在“Server服务器”栏中填入服务器地址,在账户Account和密码Password栏中填入您的VPN账号和密码,密钥Secret填入我们提供的密钥,然后点击“存储”。

然后,打开VPN开关,就可以自动连接。
Random Posts
Tags
Recent Comments
- 流云雨蝶 on 100 Best Classics Two
- can on 100 Best Maria Callas 卡拉丝名唱百分百
- Passioning on Lisa Ono 小野丽莎 – Dans Mon Île 左岸香颂
- tzewei on 《US Billboard 2009 Year-End Hot 100 Songs》(2009年美国公告牌流行金榜百首)
- Lord on 100 Best Encores