搭一个l2tp隧道,拓扑如下

两台机器是CentOS5,内核选上CONFIG_LEGACY_PTYS选项后自己编译的,l2tp是已经停更的l2tpd-0.69。先在LS上配置IP地址,iptables规则,这些不在多说,直接看l2tpd的配置文件

;/etc/l2tpd/l2tpd.conf
[global]
; if you run l2tpd on the internal interface only, enable the line below
; listen-addr = 192.168.1.98
[lns default]
ip range = 192.168.1.128- 192.168.1.254
local ip = 192.168.1.98
require chap = yes
refuse pap = yes
;下面这行说的是要PPP认证,我实际测试中感觉有没有这一行都没影响
require authentication = yes
ppp debug = yes
pppoptfile = /etc/ppp/options.l2tpd
length bit = yes

然后是LS的pppd配置文件如下

#/etc/ppp/options.l2tpd
ipcp-accept-local
ipcp-accept-remote
ms-dns 192.168.1.1
ms-dns 192.168.1.3
ms-wins 192.168.1.1
ms-wins 192.168.1.3
noccp
#noauth
auth
crtscts
idle 1800
mtu 1200
mru 1200
# change line below to defaultroute to make all traffic go through the VPN
nodefaultroute
debug
lock
proxyarp
connect-delay 5000

再然后配置pppd的认证文件

#/etc/ppp/chap-secrets
"johnsnow" * "youknownothing" 192.168.1.0/24

RS的l2tpd的配置文件如下

; Connect as a client to a server at 194.168.10.4
[lac myl2tp]
lns = 194.168.10.4
require chap = yes
refuse pap = yes
;require authentication = yes
; Name should be the same as the username in the PPP authentication!
ppp debug = yes
pppoptfile = /etc/ppp/options.l2tpd.client
length bit = yes

RS的pppd配置文件如下

#/etc/ppp/options.l2tpd.client
ipcp-accept-local
ipcp-accept-remote
refuse-eap
noccp
#noauth
noauth
crtscts
idle 1800
mtu 1200
mru 1200
#nodefaultroute
defaultroute
debug
lock
#proxyarp
connect-delay 5000

RS的pppd认证文件

#/etc/ppp/chap-secrets
"johnsnow" * "youknownothing"

分别在LS和RS上执行

l2tpd -c /etc/l2tpd/l2tpd.conf -D

最后在RS上拨号

echo "c myl2tp" >/var/run/l2tp-control

最后用ifconfig看一下,多了一个ppp接口说明拨号成功了。整个配置过程不难,但是我在配置LS的pppd配置文件时候走了一些弯路,在我配置了auth之后总是拨号不成功,最后在认证文件里最后一列加上了地址(192.168.1.0/24)才能认证成功。我猜想在LS的pppd启动的时候RS的ppp0已经分到了一个192.168.1.0/24网段的地址,导致LS的pppd认证不通过,但是我不确定,非常不确定,有时间把代码看一下。

这个配置仅仅使用了l2tp协议,并没有使用ipsec相关协议,在网络上还是明文传输的,如果要加密还需要配置ipsec。

最新文章

  1. BZOJ1642: [Usaco2007 Nov]Milking Time 挤奶时间
  2. iOS基础 - UIDatePicker and UIPickerView and UITextField
  3. CentOS 6.0找不到ifcfg-eth0解决方案
  4. 【MySQL】(4)操作数据表中的记录
  5. 虚拟机Oracle VM VirtualBox linux系统如何访问windows共享文件夹
  6. P3440 [POI2006]SZK-Schools(费用流)
  7. Android 开发 RecyclerView设置间距
  8. python框架之Django(5)-O/RM
  9. iptables后,外网访问网站可以,内网无法访问【已解决】
  10. effective c++ 笔记 (9-12)
  11. OVS 精确删除流表
  12. 转 安装Nginx 1.2.0+PHP 5.4.3(FastCGI)+MySQL 5.5.24
  13. 带分数(dfs,next_permutation)
  14. linux下mysql命令大全
  15. spring FactoryBean配置Bean
  16. CentOS7使用yum安装LNMP环境以后无法打开php页面
  17. xv6/bootasm.S + xv6/bootmain.c
  18. Oracle案例02——ORA-12034: "SCOTT"."USER_TABLE" 上的实体化视图日志比上次刷新后的内容新
  19. 20、Springboot 与数据访问(JDBC/自动配置)
  20. 会话对应的线程id

热门文章

  1. nginx模块化结构
  2. C#知识点:操作XML
  3. C015:十进制转8进制
  4. uap设置gradle和jdk
  5. RabbitMQ安装和运行
  6. css常用属性之display属性
  7. 秒懂JVM的三大参数类型,就靠这十个小实验了
  8. ASP.NET Core 配置与获取
  9. 老生常谈SpringAop日志收集与处理做的工具包
  10. SQL Server通过创建临时表遍历更新数据