吵吵   2012-04-29  阅读:6,863

多播的魅力在于使用了多播之后可以让网速加倍提升,这也许是提高宽带上限的一个不二法门。于是乎我们有了不满足双拨或者三拨了,我们要的是实现多拨,直到我们的路由器再也承受不住了才算收手。

这里有飞翔修改的一个pppd的多播脚本pppoeup,你可以放入/lib/nawan后直接启动它:
sh /lib/nwan/pppoeup
或者将上面一句代码添加到rc.local中实现我们的开机启动:
sh /lib/nwan/pppoeup

该脚本的代码如下:

# syncpppoe up Script VER 0.10a for openwrt  by feixiang<feixiang@openwrt.org.cn>

. $IPKG_INSTROOT/etc/functions.sh

start_pppd() {
        local cfg="$1"; shift

        # unique link identifier
        local link="${proto:-ppp}-$cfg"

        local device
        config_get device "$cfg" device

        local username
        config_get username "$cfg" username

        local password
        config_get password "$cfg" password

        local keepalive
        config_get keepalive "$cfg" keepalive

        local connect
        config_get connect "$cfg" connect

        local disconnect
        config_get disconnect "$cfg" disconnect

        local pppd_options
        config_get pppd_options "$cfg" pppd_options


        local interval="${keepalive##*[, ]}"
        [ "$interval" != "$keepalive" ] || interval=5

        local dns
        config_get dns "$config" dns

        local proto
        config_get proto "$cfg" proto

echo "start-stop-daemon -S -b -x /usr/sbin/pppd -m -p /var/run/ppp-$link.pid -- "$@" \
${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
$demandargs \
usepeerdns \
$defaultroute \
${username:+user "$username" password "$password"} \
ipparam "$cfg" \
ifname "$link" \
${connect:+connect "$connect"} \
${disconnect:+disconnect "$disconnect"} \
${ipv6} \
${pppd_options} \
nodetach &" >> /tmp/pppoeallup


}


config_wan_load_syncpppoeup() {
        local iface="$1"
        local config="$1"
local cfg="$1"
eval "echo $cfg|grep -q wan"
        local proto
        config_get proto "$cfg" proto
# if wan ifdown interface 
[ "$?" = 0  -a $proto = "pppoe" ] && {

config_get mtu $cfg mtu
#config_get ifname $cfg ifname
ifname=`uci get network.$iface.ifname`
ifconfig $ifname up
mtu=${mtu:-1492}
start_pppd "$config" \
plugin rp-pppoe.so syncppp \
mtu $mtu mru $mtu \
"nic-$ifname"
}
}



kill_pppd()
{
local otherpids
local execute
otherpids=$(ps -a 2>&1 | grep 'pppd' | grep -v $$ | awk -F " " '{print $1}')
echo "$otherpids" | while read execute
do
kill -9 ${execute} 
done
}

config_wan_load_ifdown(){
local cfg="$1"
eval "echo $cfg|grep -q wan"
# if wan ifdown interface 
[ "$?" = 0  ] && {

append ifdown_all_wan "ifdown ${cfg}&"
echo "wan x start down ${ifdown_all_wan}"
                wan_num=`expr $wan_num + 1`
}

}



start_all_pppoeup(){
#1 kill all wan and pppd session
        local ifdown_all_wan=""
        local wan_num=0
        config_load network
        config_foreach config_wan_load_ifdown interface
        echo "all wan down command: $ifdown_all_wan"
        eval "$ifdown_all_wan"
        kill_pppd
        kill_pppd
        kill -9 syncpppinit
        echo "wan_num=$wan_num"
#2 start  syncup pppoe 
        syncpppinit ${wan_num} &
        sleep 1

        config_load network
        echo "" > /tmp/pppoeallup
        config_foreach config_wan_load_syncpppoeup interface

        sh /tmp/pppoeallup


}

start_all_pppoeup

吵吵微信朋友圈,请付款实名加入:

吵吵 吵吵

3条回应:“pppd实现多拨脚本”

  1. tansheng说道:

    好久没来了,坐个沙发。

  2. 仰慕你的人说道:

    其实,现在的脚本多拨已经是过时的玩意了,效率很低,修改源码加入一些设置才是王道,你用的垃圾nwan平常拨3、4个就happy了,但是用另一种方法可以轻松拨10个、15个

发表评论

电子邮件地址不会被公开。 必填项已用*标注