东南大学 - SeUDigger

需要面对面帮助?请寻求当地校园社团支持!
回复
qbp
帖子: 9
注册时间: 2008-04-21 16:30
来自: nj

#76

帖子 qbp » 2008-09-09 21:23

yuancongwei 写了:我的BRAS连不上
怎么弄?
我添加好了路由的

用的虎踞龙蟠的代码

#!/bin/sh
#########################################################################
# bras: a bras controller used in Southeast University campus #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# Copyright (C) 2007 by MinHongbo <minhongbo20@163.com> #
#########################################################################

#set default user information and profiles
USER=
PASSWORD=
L2TPD=/etc/l2tpd
L2TPDCONF=/etc/l2tpd/l2tpd.conf
PPPOPTIONS=/etc/ppp/options.l2tpd
CHAPSECRET=/etc/ppp/chap-secrets
IFCONFIG_ETH0=/etc/sysconfig/network-scripts/ifcfg-eth0
SLEEP=7

#get default GATEWAY
#Note: This may be some problem in other Unix environments such as
#FreeBSD and Solaris for their networkconfig files does not located
#in /etc/sysconfig/network-scripts/*.
#GATEWAY=`awk -F= '{if($0~/GATEWAY/) print $2}' $IFCONFIG_ETH0`

#function: modify_file
#Usage: modify_file FILENAME pattern-to-find replacement-pattern
#Note: replace pattern-to-find in FILENAME with replacement-pattern
modify_file()
{
_FILE=$1
_STRING=$2
_REP=$3
if [ -e $_FILE ];then
sed "s/$_STRING/$_REP/g" $_FILE > $_FILE~
mv $_FILE~ $_FILE
rm -f $_FILE~
else
echo "$_FILE does not exist! Please check it";
fi
}
#login function for bras
logbras()
{
#get user information
DATE=`date +%F`
echo "--------------------------------------------------"
echo " Welcome to SEU Bras $DATE"
echo "--------------------------------------------------"
echo -n "Username: "
read USER
SAVEDSTTY=`stty -g`
stty -echo
echo -n "Password: "
read PASSWORD
stty $SAVEDSTTY
echo ""
echo "--------------------------------------------------"
}
#function: chconfig
#modify three configuration profiles usd in l2tpd with user name and its password
chconfig()
{
#(1)/etc/l2tpd/l2tpd.conf : name = $USER in the "lac seubras" label
if [ -e $L2TPDCONF ]; then
_PATTERN=`sed -n '/lac/, /name = */'p $L2TPDCONF | sed -n '/name = */'p`
_REPLACE="name = $USER"
modify_file "$L2TPDCONF" "$_PATTERN" "$_REPLACE"
else
echo "$L2TPDCONF does not exist!"
fi

#(2)/etc/ppp/options.l2tpd: name = $USER
#first, get ppp's options file
PPPOPTIONS=`sed -n '/lac/, /pppoptfile = */'p $L2TPDCONF | sed -n '/pppoptfile = */'p`
PPPOPTIONS=`echo $PPPOPTIONS | sed -n 's/pppoptfile = //g'p`
if [ -e $PPPOPTIONS ]; then
_PATTERN=`sed -n '/name/'p $PPPOPTIONS`
_REPLACE="name $USER"
modify_file "$PPPOPTIONS" "$_PATTERN" "$_REPLACE"
else
echo "$PPPOPTIONS does not exist!"
fi
#(3)/etc/ppp/chap-secrets: * $USER * "$PASSWORD" *
if [ -e $CHAPSECRET ]; then
sed "/^[a-zA-Z0-9]/d" $CHAPSECRET >$CHAPSECRET~
sed "/# client/ a $USER * "$PASSWORD"" $CHAPSECRET~ >$CHAPSECRET
rm -f $CHAPSECRET~
else
echo "$CHAPSECRET does not exit!"
fi
}

#add intra-campus routes
addroute()
{
echo -n "Adding intra-campus route..."
{
route add -net 172.16.0.0 netmask 255.240.0.0 gw $GATEWAY
route add -net 202.119.0.0 netmask 255.255.224.0 gw $GATEWAY
route add -net 202.119.144.0 netmask 255.255.240.0 gw $GATEWAY
route add -net 211.65.32.0 netmask 255.255.224.0 gw $GATEWAY
route add -net 202.119.24.55 netmask 255.255.255.255 gw $GATEWAY #bras.seu.edu.cn
route add -net 58.192.112.0 netmask 255.255.240.0 gw $GATEWAY #www.seu.edu.cn
route add -net 121.220.0.0 netmask 255.255.0.0 gw $GATEWAY
route add -net 121.248.53.1 netmask 255.255.255.0 gw $GATEWAY
route del default gw $GATEWAY
route add default
} >/dev/null 2>&1
echo " [ OK ]"
}
#del intra-campus routes
delroute()
{
echo -n "Deleting intra-campus routes..."
{
route del -net 172.16.0.0 netmask 255.240.0.0 gw $GATEWAY
route del -net 202.119.0.0 netmask 255.255.224.0 gw $GATEWAY
route del -net 202.119.144.0 netmask 255.255.240.0 gw $GATEWAY
route del -net 211.65.32.0 netmask 255.255.224.0 gw $GATEWAY
route del -net 202.119.24.55 netmask 255.255.255.255 gw $GATEWAY
route del -net 58.192.112.0 netmask 255.255.240.0 gw $GATEWAY
route del -net 121.229.0.0 netmask 255.255.0.0 gw $GATEWAY
route del -net 121.248.53.1 netmask 255.255.255.0 gw $GATEWAY
route del default
route add default gw $GATEWAY
} >/dev/null 2>&1
echo " [ OK ]"
}
#check whether l2tpd is running? if not, launch it.
launch_l2tpd()
{
DATE=`date +%F`
L2TPD=`pstree -p | grep l2tpd | grep -v grep`
if [ -z $L2TPD ]
then
rm -f /var/log/*@l2tpd.log
echo -n "Starting l2tpd..."
l2tpd -D 2> /var/log/"$DATE"@l2tpd.log &
if [ $? = 0 ]
then
sleep 1
echo " [ OK ]"
echo "The logging file is /var/log/$DATE@l2tpd.log."
else
echo " [FAILED]"
exit 1
fi
fi
}
#start seubras services
bras_start()
{
STATUS=`ifconfig -a | grep ppp0`
if [ "$STATUS" ]
then
echo "bras has already been actived!"
exit 0
fi
#First, run l2tpd
launch_l2tpd
#Second, add intra-campus routes
#get username in /etc/ppp/options.l2tpd
CURNAME=`awk '{if($1~/name/) print $2}' $PPPOPTIONS`
echo "$CURNAME login......"
sleep 0.5
addroute
sleep 0.5
#Third, connect bras.seu.edu.cn
echo -n "Connecting to SEU Bras server"
echo 'c seubras' > /var/run/l2tp-control
COUNT=0
until [ "$COUNT" -gt "$SLEEP" ]
do
echo -n ".."
sleep 1
COUNT=`expr $COUNT + 1`
done
STATUS=`ifconfig -a | grep ppp0`
#try 10 times
if [ "$STATUS" ]
then
echo " [ OK ]"
else
echo " [ FAILED ]"
fi
}
#stop seubras services
bras_stop()
{
CURNAME=`awk '{if($1~/name/) print $2}' $PPPOPTIONS`
echo "$CURNAME logout....."
sleep 1
delroute
sleep 1
STATUS=`ifconfig -a | grep ppp0`
if [ -z "$STATUS" ]
then
echo "bras has not been actived!"
exit 0
fi

echo -n "Disconnect from SEU bras server..."
echo 'd seubras' > /var/run/l2tp-control
if [ $? = 0 ]
then
echo " [ OK ]"
else
echo " [ FAILED ]"
fi
}

#switch actions according to $1 argument
case $1 in
route)
addroute
;;
#login seubras using latest loginfo. Alternatively, you can specify user and password by
#modify profiles(l2tpd.conf, options.l2tpd and chap-secrets) manually.
start)
bras_start
;;
#close bras connection
stop)
bras_stop
;;
#restart bras connection
restart)
bras_stop
sleep 1
bras_start
;;
#build a new bras connection with another user.
#It provides a convenient mean of switching different users,
#such as username@a and username@b
login)
logbras
#check if bras has been already launched by look up a ppp0 interface.
#if true, try to stop it.
PPP0=`ifconfig -a | grep ppp0`
if [ ! -z "$PPP0" ]
then
bras_stop
fi
sleep 1
chconfig
bras_start
;;
install)
echo "Copy configuration files..."
if [ ! -d "$L2TPD" ]
then
echo "$L2TPD does not exist."
echo -n "Creating a new directory $l2tpd ..."
mkdir $l2tpd
echo " [ OK ]"
fi
echo "copy l2tpd.conf to $L2TPDCONF" && \
cp configs/l2tpd.conf $L2TPDCONF && \
echo "copy options.l2tpd to $PPPOPTIONS" && \
cp configs/options.l2tpd $PPPOPTIONS && \
echo "copy chap-secrets to $CHAPSECRET" && \
cp configs/chap-secrets $CHAPSECRET && \
echo "OK! You can connect to bras server, try to command: bras login"
;;
help)
sed -n '1,$'p bras-help
;;
*)
echo "Usage: `basename $0 ` [ login | start | stop | restart | route | install ] "
;;
esac


红字是我自己改的部分


结果如图

1。建议你发到sbbs上,那里的高手在线的多
2。你的出错信息没有给出来
3。有情帮顶~
yuancongwei
帖子: 282
注册时间: 2007-11-18 15:52
来自: 江苏盛泽医院普外科

#77

帖子 yuancongwei » 2008-09-10 22:16

遇到新问题
我用的是虎踞龙蟠0.2的脚本

编译成功后
变成这样


但是依旧无法上网
您没有权限查看这个主题的附件。
yuancongwei
帖子: 282
注册时间: 2007-11-18 15:52
来自: 江苏盛泽医院普外科

#78

帖子 yuancongwei » 2008-09-10 22:18

[quote=]1。建议你发到sbbs上,那里的高手在线的多
2。你的出错信息没有给出来
3。有情帮顶~[/quote]

虎踞龙蟠我登录不上
yuancongwei
帖子: 282
注册时间: 2007-11-18 15:52
来自: 江苏盛泽医院普外科

#79

帖子 yuancongwei » 2008-09-11 12:32

已解决
ai_linux
帖子: 3
注册时间: 2008-09-28 11:41

Re: 东南大学 - SeUDigger

#80

帖子 ai_linux » 2008-09-28 18:57

顶!自己人。qq:543862910.
支持linux,支持opensource
521rabbit
帖子: 4
注册时间: 2008-07-11 14:13

Re: 东南大学 - SeUDigger

#81

帖子 521rabbit » 2009-11-07 9:28

顶!!
回复