你可以上google找l2tpd相关资料
我也是刚接触ubuntu。。。
其实那篇文章确实有点乱。。。
88ftp是校内镜像,其实不过是l2tpd的客户端,可以去
http://packages.ubuntu.com/gutsy/net/l2tpd下载
xl2tpd是l2tpd的更新版本,ubuntu直到hardy才用。gutsy还是只有l2tpd。
上面的文章专为浙大使用的,可是应该差不多哦吧。。。
我说一下我的方法吧,仅供参考。。
l2tpd没有图形界面(如果有一定要告诉我。。),所以
要手动配置文件,通常在/etc/l2tpd/l2tpd.conf中,而xl2tpd则为/etc/xl2tpd/xl2tpd.conf(以sudo gedit修改。。。)
格式为
[global] ; Global parameters:
port = 1701 ; * Bind to port 1701
[lac zju] ; Example VPN LAC definition
lns = lns.zju.edu.cn ; * Who is our LNS?
refuse pap = yes ; * Refuse PAP authentication
require authentication = no ; * Require peer to authenticate
name = zealot@a ; * Report this as our hostname
ppp debug = yes ; * Turn on PPP debugging
pppoptfile = /etc/l2tpd/zju.options ; * ppp options file for this lac
lns为学校给的,name也是学校给的。
接下来安装ppp,ubuntu packages里有,然后按上面pppotfile的位置填写。
(sudo gedit /etc/l2tpd/zju.options,没有就建一个)
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
然后是密码文件,由于使用 chap 方式验证,密码文件默认放在 /etc/ppp/chap-secrets 里面(另一种方式我就不懂了。。。填写password的位置):
# Secrets for authentication using CHAP
# client server secret IP addresses
* * password *
然后以“/etc/init.d/l2tpd start”启动l2tpd
(不行就试试sudo,我是这样搞来的。。)
然后输入echo "c zju" > /var/run/l2tp-control
(zju按什么规律修改。。我不知道。。希望英明的你能发现吧。。)
*好像要先输入
$ sudo chmod 666 /etc/l2tpd/l2tpd.conf
$ sudo chmod 666 /etc/l2tpd/zju.options
$ sudo chmod 666 /etc/ppp/chap-secrets
$ sudo chmod 666 /var/run/l2tp-control
(如果是xl2tpd,要自己修改,l2tp-control好像是不用修改的,详情可以在启动l2tpd之后,在var/run中找看看有没有这个文件)
等几秒后(可能几十秒。。。),输入ifconfig看看有没有ppp。。。
有的话你成功了。。。没有的话。。我不会,我是新手。。。。
然后就是调路由了,一般已经很轻松了。。。要让校内网由原本的ip,而外网使用新的ppp的ip
无论如何,你可以先加如学校lns的ip route,印象中好像要加sudo的
ip route add 10.0.0.0/8 via 222.205.9.1 dev eth0
(10.0.0.0是你学校的校内网号码,总之lns的那个一定要加,222.205.9.1是你的ifconfig中eth0里显示的,也可能是eth1等,自己判断。)
ip route del default
ip route add default via $PPP dev ppp0
$PPP是你在ifconfig中的ppp0中的号码。。。
这里应该可以上网了。。。(祝你好运,我弄了好久好久。。。如果不是因为这个,ubuntu本来应该很顺利的。。。)
之后可以直接建立脚本文件,如vpn.sh,修改为可执行文件。。。(chmod +x,然后以 sudo ./vpn.sh执行)
脚本中写入
#!/bin/bash
########################################
# Shell script to (re)connect to VPN
# pluskid <pluskid.zju@gmail.com>
########################################
####################
# Variables
####################
## How many seconds to wait for the ppp0 to come up each try
TIMEOUT=20
## How many times to try to bring up ppp0 until fail
N_RETRY=3
## Interface default to use
INTERFACE=eth0
## How many seconds to wait for l2tpd to restart
L2TPD_TIMEOUT=10
## For xl2tpd: /etc/init.d/xl2tpd
## For l2tpd: /etc/init.d/l2tpd
L2TPD_SCRIPT=/etc/init.d/l2tpd
## For xl2tpd: /var/run/xl2tpd/l2tp-control
## For l2tpd: /var/run/l2tp-control
L2TPD_PIPE=/var/run/l2tp-control
####################
# Commands
####################
function usage
{
echo "$1 login to the school VPN."
echo "$1 [-h] [-r]"
echo " Default to connect to VPN."
echo " -r reconnect."
echo " -h help, i.e. show this information."
}
function connect
{
if ppp0_alive ; then
echo "Already connected."
else
bring_up_ppp0 && setup_route
fi
}
function reconnect
{
restart_l2tpd && bring_up_ppp0 && setup_route
}
####################
# Internal utility functions
####################
function super_user
{
if [ "$UID" = "0" ]; then
return 0 # Yes, super user
else
return 1
fi
}
function ppp0_alive
{
if ifconfig | grep -s 'ppp0' > /dev/null ; then
return 0 # Yes, connected
else
return 1
fi
}
function bring_up_ppp0
{
for i in $(seq $N_RETRY)
do
echo -n "Trying to bring up ppp0"
echo "c zju" > $L2TPD_PIPE
for j in $(seq $TIMEOUT)
do
if ppp0_alive; then
echo " Done!"
return 0 # Yes, brought up!
fi
echo -n "."
sleep 1
done
echo
done
echo "ERROR: Failed to bring up ppp0!"
return 1
}
function setup_route
{
echo "Setting up route..."
STATIC=$(ip route | grep '^default' | cut -d" " -f3)
# If already set the route before, we cannot find
# the original default route any more. But fortunately,
# the route previously setted often won't change and
# we can just safely ignore this task
if [ ! -z $STATIC ]; then
ip route add 10.0.0.0/8 via $STATIC dev $INTERFACE
ip route add 222.205.0.0/16 via $STATIC dev $INTERFACE
ip route add 210.32.0.0/16 via $STATIC dev $INTERFACE
ip route add 239.43.1.1 via $STATIC dev $INTERFACE
ip route del default
fi
PPP=$(ifconfig | sed -n '/P-t-P/s/^.*P-t-P:\([0-9.]*\).*$/\1/p')
ip route add default via $PPP dev ppp0
echo "Done!"
}
function restart_l2tpd
{
echo "Restarting l2tpd..."
$L2TPD_SCRIPT restart
for i in $(seq $L2TPD_TIMEOUT)
do
if [ -e $L2TPD_PIPE ]; then
echo "Done!"
return 0 # Successfully restarted!
fi
sleep 1
done
echo "ERROR: Failed to restart l2tpd!"
return 1 # Failed to restart l2tpd
}
####################
# Main
####################
if ! super_user ; then
echo "ERROR: You must be super user to run this utility!"
exit 1
fi
if [ $# -lt 1 ]; then
connect
elif [ "$1" = "-h" ]; then
usage
else
reconnect
fi
关键是这段,似乎要照你学校的修改。。。我不清楚。。。我是新手。。。
ip route add 10.0.0.0/8 via $STATIC dev $INTERFACE
ip route add 222.205.0.0/16 via $STATIC dev $INTERFACE
ip route add 210.32.0.0/16 via $STATIC dev $INTERFACE
ip route add 239.43.1.1 via $STATIC dev $INTERFACE
然后注意如果是中文环境的话,将function setup_route中的P-t-P改成“点对点”,具体见下面.
PPP=$(ifconfig | sed -n '/P-t-P/s/^.*P-t-P:\([0-9.]*\).*$/\1/p')
PPP=$(ifconfig | sed -n '/点对点/s/^.*点对点:\([0-9.]*\).*$/\1/p')