วันพฤหัสบดีที่ 18 พฤศจิกายน พ.ศ. 2553

ตัวอย่าง Script 5WAN (Wan ละ 4M) โหลดบาลานซ์ทั้ง 5 เส้น ไม่แยกเกมส์

ไฟล์  /etc/ppp/ip-up.d/0route

#!/bin/sh
        droute=""
        ppp101=`/sbin/ifconfig -a | grep "ppp101"`
        if [ -n "$ppp101" ]; then
                # echo "ppp101 is up"
                status=`expr $status + 1`
                ip route add default table 101 dev ppp101
                ip route add default table 201 dev ppp101
                IPWAN=`ip addr show ppp101 |grep inet |cut -d " " -f 6`
                ip rule del prio 201
                ip rule add from $IPWAN lookup 201 prio 201
                droute="$droute nexthop dev ppp101 weight 4"
        fi
        ppp102=`/sbin/ifconfig -a | grep "ppp102"`
        if [ -n "$ppp102" ]; then
                # echo "ppp102 is up"
                status=`expr $status + 2`
                ip route add default table 102 dev ppp102
                ip route add default table 202 dev ppp102
                IPWAN=`ip addr show ppp102 |grep inet |cut -d " " -f 6`
                ip rule del prio 202
                ip rule add from $IPWAN lookup 202 prio 202
                droute="$droute nexthop dev ppp102 weight 4"
        fi
        ppp103=`/sbin/ifconfig -a | grep "ppp103"`
        if [ -n "$ppp103" ]; then
                # echo "ppp103 is up"
                status=`expr $status + 4`
                ip route add default table 103 dev ppp103
                ip route add default table 203 dev ppp103
                IPWAN=`ip addr show ppp103 |grep inet |cut -d " " -f 6`
                ip rule del prio 203
                ip rule add from $IPWAN lookup 203 prio 203
                droute="$droute nexthop dev ppp103 weight 4"
        fi
        ppp104=`/sbin/ifconfig -a | grep "ppp104"`
        if [ -n "$ppp104" ]; then
                # echo "ppp104 is up"
                status=`expr $status + 8`
                ip route add default table 104 dev ppp104
                ip route add default table 204 dev ppp104
                IPWAN=`ip addr show ppp104 |grep inet |cut -d " " -f 6`
                ip rule del prio 204
                ip rule add from $IPWAN lookup 204 prio 204
                droute="$droute nexthop dev ppp104 weight 4"
        fi
        ppp105=`/sbin/ifconfig -a | grep "ppp105"`
        if [ -n "$ppp105" ]; then
                # echo "ppp105 is up"
                status=`expr $status + 16`
                ip route add default table 105 dev ppp105
                ip route add default table 205 dev ppp105
                IPWAN=`ip addr show ppp105 |grep inet |cut -d " " -f 6`
                ip rule del prio 205
                ip rule add from $IPWAN lookup 205 prio 205
                droute="$droute nexthop dev ppp105 weight 4"
        fi
        if [ -n "$droute" ]; then
                ip route del default
                ip route del table 250 default
                defroute="ip route add default equalize $droute"
                defroute2="ip route add table 250 default equalize $droute"
                `$defroute`
                `$defroute2`
        fi
ip route flush cache

ไม่มีความคิดเห็น:

แสดงความคิดเห็น