| 分类: Linux技术 |
设置环境:ubuntu6.04
步骤:
1. 安装相应软件
# apt-get install ppp l2tpd
2. 编辑/etc/l2tpd/l2tpd.conf(这里的例子中有2个连接)
[global]
; Global parameters:
port =
1701
; * Bind to port 1701 [lac
zju1] ;
连接名,可设置多个连接
name = zealot@a
; VPN 的帐号名,别忘加@a/b/c/d
lns =
lns.zju.edu.cn
; 学校的VPN服务器
refuse pap = yes
; * Refuse PAP authentication
require authentication = no
;
ppp debug =
yes
; 打开debug
pppoptfile = /etc/l2tpd/zju.options
; 这个连接的配置文件名
name =
refuse pap = yes
require authentication = no
pppoptfile = /etc/l2tpd/zju.options
[lac
zju2] ;
连接名,可设置多个连接
name = asci@a
; VPN
的帐号名,别忘加@a/b/c/d
lns =
lns.zju.edu.cn
; 学校的VPN服务器
refuse pap = yes
; * Refuse PAP authentication
require authentication = no
;
ppp debug =
yes
; 打开debug
pppoptfile = /etc/l2tpd/zju.options
; 这个连接的配置文件名
name =
refuse pap = yes
require authentication = no
pppoptfile = /etc/l2tpd/zju.options
3.
编辑/etc/l2tpd/zju.options(l2tpd.conf中定义的配置文件):
asyncmap 0
noauth
crtscts
lock
hide-password
modem
netmask 255.255.255.0
proxyarp
lcp-echo-interval 30
lcp-echo-failure 4
ipcp-accept-local
ipcp-accept-remote
noipx
noauth
crtscts
lock
hide-password
modem
netmask 255.255.255.0
proxyarp
lcp-echo-interval 30
lcp-echo-failure 4
ipcp-accept-local
ipcp-accept-remote
noipx
4. 编辑/etc/ppp/chap-secrets,为帐号设置密码
# Secrets for authentication using CHAP
# client
server
secret
IP addresses
asci@a lns.zju.edu.cn
"password"
*
# Secrets for authentication using CHAP
# client
#!/bin/bash
function connect
{
COUNT=0
echo "c
zju1" >
/var/run/l2tp-control
{
}
if [ $# = 1 ]; then
if [ $1 = -r
]; then
/etc/init.d/l2tpd restart
# waiting for l2tpd to startup
#while ! test -f /var/run/l2tp-control ; do
sleep 5
#done
connect
ROUTE=$(ifconfig | grep P-t-P | awk '{print $3}' | cut -d':'
-f2)
ip route add default via $ROUTE dev ppp0
fi
else
if !
ifconfig | grep -s 'ppp0' > /dev/null; then
connect
IP=$(ip route | grep '^default' | cut -d" " -f3)
ROUTE=$(ifconfig | grep P-t-P | awk '{print $3}' | cut -d':'
-f2)
ip route add 10.0.0.0/8 via $IP dev eth0
ip route add 222.205.0.0/16 via $IP dev eth0
ip route add 210.32.0.0/16 via $IP dev eth0
ip route add 239.43.1.1/24 via $IP dev eth0
ip route del default
ip route add default via $ROUTE dev ppp0
else
echo 'already connected...'
fi
fi
else
fi
6. 连接实验:运行
#
/etc/init.d/l2tpd start
# chmod
+755 /etc/init.d/vpninit.sh
#
/etc/init.d/vpninit.sh
再运行ifconfig,看有没有ppp0的interface,如果有就是成功了。
再运行ifconfig,看有没有ppp0的interface,如果有就是成功了。
(如果成功则跳到第8步:启动设置和自动重连)
7. debug
先停止l2tpd工作,并打开一个前台的l2tpd工作台
# /etc/init.d/l2tpd stop
# l2tpd -D
这样,这个终端就被l2tpd占据
然后从另一个终端输入命令(假设要测试 连接 zju1):
# echo "c zju1" >
/var/run/l2tp-control
然后看l2tpd终端的输出,特别是ppp的返回值,然后多man一下,一般能解决问题的。
8.
启动设置和自动重连设置(待以后更新)
------------------
END





加载中…