Vyatta下vpn使用设置之l2tp


Vyatta支持三种类型的vpn:pptp、l2tp/ipsec、openvpn,个人看好l2tp的方式,l2tp的使用方式又分为'Pre-Shared Key'与'X.509 Certificates'这两种方式,在配置指令上所所区别。
Pre-Shared Key:顾名思义,即预先约定的短语字串。它除了使用用户名密码登录外,另外多了一层安全保障,用户名密码或这个key其中一个外泄都不会让得到者登录vpn服务器。
在配置之前,我们需要知道的相关参数有:vpn服务器的公网地址、vpn的类型(l2tp)、该类型的使用方式、用于分配的ip地址池、为拨号成功的用户准备的dns服务器、登录用的用户名及密码、登录的验证方式等。
由于l2tp本身不能提供加密支持,因此需要借助于第三方的技术进行加密,多数情况下与之搭配的是ipsec,因此需要先配置ipsec模块。
set vpn ipsec ipsec-interfaces interface eth0
set vpn ipsec nat-traversal enable
set vpn ipsec nat-networks allowed-network 0.0.0.0/0
commit
注:这里的eth0口为软路由的公网口,它有固定的公网ip地址;同时还要强制为其开启NAT traversal服务;一般将allowed-network设定为内网的ip地址段,如果有多个私有段,则可以写成上面的方式。
#####
set vpn l2tp remote-access outside-address public_ip_addr
set vpn l2tp remote-access client-ip-pool start 10.0.0.101
set vpn l2tp remote-access client-ip-pool stop 10.0.0.254
上面定义了可供分配的ip地址段,可据实际情况来定。
set vpn l2tp remote-access ipsec-settings authentication mode pre-shared-secret
set vpn l2tp remote-access ipsec-settings authentication pre-shared-secret freeoa_vpn_sec
上面定义了使用pre-shared key方式
set vpn l2tp remote-access authentication mode local
set vpn l2tp remote-access authentication local-users username freeoa password mypass
定义了使用本地内置的认证方式
set vpn l2tp remote-access authentication mode radius
set vpn l2tp remote-access authentication radius-server 10.1.5.222 key abcxyz
定义了使用radius进行身份认证,注意:radius如果使用了ldap作为其后端用户源的话,则在使用vpn登录时不能选择到服务器登录时也启用加密的方式,即明文登录vpn。
这里看一个配置示例:
# show vpn l2tp
remote-access {
authentication {
local-users {
username homeuser {
password www.freeoa.net
static-ip 192.168.30.168
}
username zheng {
password 20_2386
}
}
mode local
}
client-ip-pool {
start 192.168.30.60
stop 192.168.30.89
}
dns-servers {
server-1 8.8.8.8
server-2 202.96.209.133
}
ipsec-settings {
authentication {
mode pre-shared-secret
pre-shared-secret freeoa_vpn_sec
}
ike-lifetime 3600
}
outside-address 218.56.78.218
}
上面还为特定的用户分配固定的ip地址。这里再看一个使用radius验证的配置示例:
nhrouter# show vpn l2tp
remote-access {
authentication {
mode radius
radius-server 192.168.20.2 {
key sig_nh_sec
}
}
client-ip-pool {
start 10.0.0.10
stop 10.0.0.254
}
dns-servers {
server-1 8.8.8.8
server-2 202.96.209.132
}
ipsec-settings {
authentication {
mode pre-shared-secret
pre-shared-secret freeoa_vpn_sec
}
}
outside-address 180.12.34.188
}
如果有多个公网出口的话,还需要为vpn指定默认为的网关:
# set vpn l2tp remote‐access outside‐nexthop gw_ip_addr
查看在线的用户:
$ show vpn remote-access
Active remote access VPN sessions:
User Proto Iface Tunnel IP TX byte RX byte Time
---- ----- ----- --------- ------- ------- ----
homeuser L2TP l2tp0 192.168.30.8 454 1.0K 00h19m09s
将在后面继续介绍使用L2TP/IPsec with X.509 Certificates的登录方式...
Pre-Shared Key:顾名思义,即预先约定的短语字串。它除了使用用户名密码登录外,另外多了一层安全保障,用户名密码或这个key其中一个外泄都不会让得到者登录vpn服务器。
在配置之前,我们需要知道的相关参数有:vpn服务器的公网地址、vpn的类型(l2tp)、该类型的使用方式、用于分配的ip地址池、为拨号成功的用户准备的dns服务器、登录用的用户名及密码、登录的验证方式等。
由于l2tp本身不能提供加密支持,因此需要借助于第三方的技术进行加密,多数情况下与之搭配的是ipsec,因此需要先配置ipsec模块。
set vpn ipsec ipsec-interfaces interface eth0
set vpn ipsec nat-traversal enable
set vpn ipsec nat-networks allowed-network 0.0.0.0/0
commit
注:这里的eth0口为软路由的公网口,它有固定的公网ip地址;同时还要强制为其开启NAT traversal服务;一般将allowed-network设定为内网的ip地址段,如果有多个私有段,则可以写成上面的方式。
#####
set vpn l2tp remote-access outside-address public_ip_addr
set vpn l2tp remote-access client-ip-pool start 10.0.0.101
set vpn l2tp remote-access client-ip-pool stop 10.0.0.254
上面定义了可供分配的ip地址段,可据实际情况来定。
set vpn l2tp remote-access ipsec-settings authentication mode pre-shared-secret
set vpn l2tp remote-access ipsec-settings authentication pre-shared-secret freeoa_vpn_sec
上面定义了使用pre-shared key方式
set vpn l2tp remote-access authentication mode local
set vpn l2tp remote-access authentication local-users username freeoa password mypass
定义了使用本地内置的认证方式
set vpn l2tp remote-access authentication mode radius
set vpn l2tp remote-access authentication radius-server 10.1.5.222 key abcxyz
定义了使用radius进行身份认证,注意:radius如果使用了ldap作为其后端用户源的话,则在使用vpn登录时不能选择到服务器登录时也启用加密的方式,即明文登录vpn。
这里看一个配置示例:
# show vpn l2tp
remote-access {
authentication {
local-users {
username homeuser {
password www.freeoa.net
static-ip 192.168.30.168
}
username zheng {
password 20_2386
}
}
mode local
}
client-ip-pool {
start 192.168.30.60
stop 192.168.30.89
}
dns-servers {
server-1 8.8.8.8
server-2 202.96.209.133
}
ipsec-settings {
authentication {
mode pre-shared-secret
pre-shared-secret freeoa_vpn_sec
}
ike-lifetime 3600
}
outside-address 218.56.78.218
}
上面还为特定的用户分配固定的ip地址。这里再看一个使用radius验证的配置示例:
nhrouter# show vpn l2tp
remote-access {
authentication {
mode radius
radius-server 192.168.20.2 {
key sig_nh_sec
}
}
client-ip-pool {
start 10.0.0.10
stop 10.0.0.254
}
dns-servers {
server-1 8.8.8.8
server-2 202.96.209.132
}
ipsec-settings {
authentication {
mode pre-shared-secret
pre-shared-secret freeoa_vpn_sec
}
}
outside-address 180.12.34.188
}
如果有多个公网出口的话,还需要为vpn指定默认为的网关:
# set vpn l2tp remote‐access outside‐nexthop gw_ip_addr
查看在线的用户:
$ show vpn remote-access
Active remote access VPN sessions:
User Proto Iface Tunnel IP TX byte RX byte Time
---- ----- ----- --------- ------- ------- ----
homeuser L2TP l2tp0 192.168.30.8 454 1.0K 00h19m09s
将在后面继续介绍使用L2TP/IPsec with X.509 Certificates的登录方式...