mac 手动添加路由

2017-8-30 vpn

查看路由:

netstat -nr

添加路由不走vpn通道:

sudo route add 112.124.184.150/8 192.168.1.253

标签: vpn route

评论(0) 浏览(1121)

vps ubuntu 搭建 ipsec l2tp vpn服务器

2016-9-19 vpn

由于升级了ios10,ios10不支持pptp vpn服务器连接,因此重新安装了下vpn服务器采用ipsec + xl2tpd

参考:https://raymii.org/s/tutorials/IPSEC_L2TP_vpn_with_Ubuntu_14.04.html


1.安装ppp openswan xl2tpd

sudo apt-get install openswan xl2tpd ppp lsof

2.设置防火墙,如果没设置的话连接成功后没办法接上外网

iptables -t nat -A POSTROUTING -j SNAT --to-source vps主机ip -o eth0(主机ip网卡)

修改/etc/sysctl.conf设置以下几个选项:

net.ipv4.ip_forward = 1

net.ipv4.conf.all.accept_redirects = 0

net.ipv4.conf.all.send_redirects = 0

net.ipv4.conf.default.rp_filter = 0

net.ipv4.conf.default.accept_source_route = 0

net.ipv4.conf.default.send_redirects = 0

net.ipv4.icmp_ignore_bogus_error_responses = 1

然后sudo sysctl -p应用他们

可以通过修改/etc/rc.local实现开机设置:把如下一条命令放在exit 0之前

iptables -t nat -A POSTROUTING -j SNAT --to-source vps主机ip -o eth0(主机ip网卡)

3.配置ipsec /etc/ipsec.conf

version 2 # conforms to second version of ipsec.conf specification

config setup
    dumpdir=/var/run/pluto/
    #in what directory should things started by setup (notably the Pluto daemon) be allowed to dump core?

    nat_traversal=yes
    #whether to accept/offer to support NAT (NAPT, also known as "IP Masqurade") workaround for IPsec

    virtual_private=%v4:10.0.0.0/8,%v4:192.168.0.0/16,%v4:172.16.0.0/12,%v6:fd00::/8,%v6:fe80::/10
    #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.

    protostack=netkey
    #decide which protocol stack is going to be used.

    force_keepalive=yes
    keep_alive=60
    # Send a keep-alive packet every 60 seconds.

conn L2TP-PSK-noNAT
    authby=secret
    #shared secret. Use rsasig for certificates.

    pfs=no
    #Disable pfs

    auto=add
    #the ipsec tunnel should be started and routes created when the ipsec daemon itself starts.

    keyingtries=3
    #Only negotiate a conn. 3 times.

    ikelifetime=8h
    keylife=1h

    ike=aes256-sha1,aes128-sha1,3des-sha1
    phase2alg=aes256-sha1,aes128-sha1,3des-sha1
    # https://lists.openswan.org/pipermail/users/2014-April/022947.html
    # specifies the phase 1 encryption scheme, the hashing algorithm, and the diffie-hellman group. The modp1024 is for Diffie-Hellman 2. Why 'modp' instead of dh? DH2 is a 1028 bit encryption algorithm that modulo's a prime number, e.g. modp1028. See RFC 5114 for details or the wiki page on diffie hellmann, if interested.

    type=transport
    #because we use l2tp as tunnel protocol 
		

left=vps主机ip

#fill in server IP above leftprotoport=17/1701 right=%any rightprotoport=17/%any dpddelay=10 # Dead Peer Dectection (RFC 3706) keepalives delay dpdtimeout=20 # length of time (in seconds) we will idle without hearing either an R_U_THERE poll from our peer, or an R_U_THERE_ACK reply. dpdaction=clear # When a DPD enabled peer is declared dead, what action should be taken. clear means the eroute and SA with both be cleared.
4.设置共享密匙 /etc/ipsec.secrets

vps主机ip %any: PSK "随便字符串"

5.验证ipsec设置

ipsec verify

Checking your system to see if IPsec got installed and started correctly:
Version check and ipsec on-path                                 [OK]
Linux Openswan U2.6.38/K3.13.0-24-generic (netkey)
Checking for IPsec support in kernel                            [OK]
 SAref kernel support                                           [N/A]
 NETKEY:  Testing XFRM related proc values                      [OK]
    [OK]
    [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 /bin/sh is not /bin/dash                               [WARNING]
Checking for 'iptables' command                                 [OK]
Opportunistic Encryption Support                                [DISABLED]
6.配置xl2tpd.conf

[global]
ipsec saref = yes
saref refinfo = 30

;debug avp = yes
;debug network = yes
;debug state = yes
;debug tunnel = yes

[lns default]
ip range = 192.168.1.20-192.168.1.100
local ip = 192.168.1.1
refuse pap = yes
require authentication = yes
;ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes
7.配置ppp /etc/ppp/options.xl2tpd 

require-mschap-v2
ms-dns 8.8.8.8
ms-dns 8.8.4.4
auth
mtu 1200
mru 1000
crtscts
hide-password
modem
name l2tpd
proxyarp
lcp-echo-interval 30
lcp-echo-failure 4

8.添加用户 /etc/ppp/chap-secrets

bob            l2tpd   DF98F09F74C06A2F             *

10.重启服务

/etc/init.d/ipsec restart 
/etc/init.d/xl2tpd restart
问题1:

Two or more interfaces found, checking IP forwarding        [FAILED]

这个可以不用管,通过echo 0 > /proc/sys/net/ipv4/ip_forward 可以解决,但是这样就没办法上外网了


问题2:

"L2TP-PSK-noNAT"[33]  #33: STATE_QUICK_R2: IPsec SA established transport mode {DPD=enabl}

拨号上去到出现上面语句后后就没相应了,原因是配置文件漏了,重新检查下配置文件就可以了

		


标签: vpn ipsec l2tp

评论(0) 浏览(1658)

vps ubuntu 通过pptpd freeradius radiusclient搭建vpn服务器

2016-8-15 vpn

vps服务器使用的是digitalocean服务器。地址为https://www.digitalocean.com/

pptpd跟freeradius radiusclient配合网上教程很多,大部分教程都是大同小异,前面参考了好多配置都是死活不成功!

今天重新下载配置了下,奇迹般的可以了!后面总结出来应该是设置账号的时候设置为之错了!

新增帐号应该放在/etc/freeradius/users 里面原先的测试帐号steve的位置下面,不应该放在文件末尾

最后参考的pptpd等配置网址为:

http://www.cnblogs.com/klobohyz/archive/2012/02/04/2338675.html

http://www.cnblogs.com/klobohyz/archive/2012/02/01/2334811.html

另radius读取/usr/local/etc/radiusclient/dictionary 配置出现了不识别的类型,把如下的注释掉就可以

#

#       RFC3162 IPv6 attributes

#

#ATTRIBUTE      NAS-IPv6-Address        95      string

#ATTRIBUTE      Framed-Interface-Id     96      string

#ATTRIBUTE      Framed-IPv6-Prefix      97      ipv6prefix

#ATTRIBUTE      Login-IPv6-Host         98      string

#ATTRIBUTE      Framed-IPv6-Route       99      string

#ATTRIBUTE      Framed-IPv6-Pool        100     string

#

#       RFC6911 IPv6 attributes

#

#ATTRIBUTE      Framed-IPv6-Address     168     ipv6addr

#ATTRIBUTE      DNS-Server-IPv6-Address 169     ipv6addr

#ATTRIBUTE      Route-IPv6-Information  170     ipv6prefix



标签: vpn pptpd freeradius radiusclient

评论(0) 浏览(1068)

Powered by EMLOG Copyright @ 狼酒 版权所有. 闽ICP备14012694号-2