
1 haruhi 2015-01-04 15:00:16 +08:00 用的是 Openswan 吧?换成 Libreswan 或者 strongSwan 吧。 |
3 yadonchen 2015-01-04 18:19:21 +08:00 yum 上的 OpenSwan 不兼容 iOS。请换用 Strongswan。已验证。 |
4 Totoria 2015-01-04 18:23:47 +08:00 换强壮天鹅! |
7 zlzhdark OP 教程已经找到,并且设置好,iphone轻松链接,win7也可以连接,安卓没试。 http://qiaodahai.com/setup-l2tp-ipsec-vpn-on-centos.html |
9 br00k 2015-01-04 21:18:11 +08:00 L2TP不错,,,PPTP很多网络环境下都没法用。 |
13 afage 2015-04-15 20:10:12 +08:00 搬瓦工怎么设置 l2tp+IPsec,小白求教程 |
14 zlzhdark OP 之前 PPTP 和 OpenVPN ,但 PPTP 太弱,而 OpenVPN 太依第三方,因此想看 L2TP/IPsec 架的使用 epel 上的 strongSwan 和 xl2tpd ,不用 openSwan 是因 OSX 在的候遇到伺服器端,是 openSwan 本身的 安前先把必要套件完 yum install strongswan xl2tpd strongSwan 完之後可以在 /etc/strongswan 定,的 strongswan.conf 特定不需要去,是所有 plugin 都入 在之前,得先整 kernel 和 iptables sed -i 's/net.ipv4.ip_forward[ ]*=[ ]*0/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf && sysctl -p # ip_forward # 防火供考 iptables -A INPUT -p udp --dport 500 -j ACCEPT # IKE iptables -A INPUT -p udp --dport 4500 -j ACCEPT # NAT-T iptables -A INPUT -p udp -m policy --dir in --pol ipsec -m udp --dport 1701 -j ACCEPT # 制 l2tp 透 ipsec 存取 iptables -t nat -A POSTROUTING -s 172.16.1.0/24 -o eth0 -j MASQUERADE # 送 VPN 流量 /etc/init.d/iptables save 接著始定 IPsec 部分,我使用 PSK ,其他方法可以上官文件查 /etc/strongswan/ipsec.conf config setup conn %default ikelifetime=60m keylife=20m rekeymargin=3m keyingtries=1 conn l2tp keyexchange=ikev1 # IKE 版本 left=>>>>{外 IP}<<<<<< leftsubnet=0.0.0.0/0 leftprotoport=17/1701 # l2tp udp 流量 authby=secret # PSK leftfirewall=no # 不要 strongswan 更改防火 right=%any # 任意 IP rightprotoport=17/%any # 任意 port udp 流量 type=transport # ipsec transport mode auto=add /etc/strongswan/ipsec.secrets # ipsec.secrets - strongSwan IPsec secrets file : PSK "A long preshared key for ipsec" IPsec 定和路上的不一是因新的 strongswan 使用 charon 理 IKEv1 ,而不是以往的 pluto 而且有候定太多反而有一些奇怪的,於是就留值 如此一 IPsec 的部分就完成了,再是 L2TP /etc/xl2tpd/xl2tpd.conf [global] listen-addr = >>>>{外 IP}<<<< [lns default] ip range = 172.16.1.100-172.16.1.200; VPN 使用者配的 IP 段 local ip = 172.16.1.1; VPN Server 本身的 IP assign ip = yes ;refuse chap = yes ;refuse pap = yes <<<我人得有 ipsec 使用 pap ,而且某些情下(例如 pam),必使用 require authentication = yes unix authentication = yes; 使用 pam ,用密得掉行 name = NyanVPNServer; 名字等一下用到,可以任意取名 ppp debug = yes pppoptfile = /etc/ppp/options.xl2tpd length bit = yes 如果上面的 xl2tpd.conf 使用了 pam ,要修改下面 /etc/pam.d/ppp #%PAM-1.0 auth required pam_nologin.so auth required pam_unix.so account required pam_unix.so session required pam_unix.so PPP 的部分 /etc/ppp/options.xl2tpd ipcp-accept-local ipcp-accept-remote ms-dns 8.8.8.8 # 推送的 DNS ms-dns 8.8.4.4 # 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 mtu 1200 # 我也不知道 mtu/mru 怎,不 mru 1200 nodefaultroute debug lock proxyarp connect-delay 5000 login # 透 PAP 使用系密,也是什前面不能拒 PAP 的原因 #require-mschap-v2 迫使用 MS-CHAP-V2 最後是密, CHAP 和 PAP 的密是分的,依照前面定的容和使用者的而定 /etc/ppp/*-secrets # Secrets for authentication using PAP # client() server(前面提到的 name) secret(密) IP addresses(配的 IP) alice NyanVPNServer "AliceIsCute" * # 下面是 PAM 的用法 * NyanVPNServer "" * 定就到止,接著就可以 VPN 了 service strongswan start service xl2tpd start 成功上 VPN 之後,如果法外,查看看 iptables 的 FORWARD chain 是不是有阻的行 |