ถ้าใช้สำหรับเล่นเน็ตอย่างเดียว ก็สามารถ ใช้ default route ได้เลยโดยใช้คำสั่ง
ip route replace default equalize nexthop dev ppp101 weight 2 nexthop dev ppp102 weight 2 nexthop dev ppp103 weight 2 nexthop dev ppp104 weight 2
ได้เลยครับและต้องเพิ่ม Script สำหรับ checklink.sh และ 0route กรณีมีเส้นใดเส้นหนึ่งหลุดไป ก็ให้ทำการวิ่งเส้นที่เหลือแทน
/etc/init.d/checklink.sh
-------------------------------------------------
#!/bin/sh
oldstatus=0
while [ 1 ]
do
status=0
ppp101=`/sbin/ifconfig -a | grep "ppp101"`
if [ -n "$ppp101" ]; then
# echo "ppp101 is up"
status=`expr $status + 1`
fi
ppp102=`/sbin/ifconfig -a | grep "ppp102"`
if [ -n "$ppp102" ]; then
# echo "ppp102 is up"
status=`expr $status + 2`
fi
ppp103=`/sbin/ifconfig -a | grep "ppp103"`
if [ -n "$ppp103" ]; then
# echo "ppp103 is up"
status=`expr $status + 4`
fi
ppp104=`/sbin/ifconfig -a | grep "ppp104"`
if [ -n "$ppp104" ]; then
# echo "ppp104 is up"
status=`expr $status + 8`
fi
if [ $status != $oldstatus ]; then
/etc/ppp/ip-up.d/0route
fi
oldstatus=$status
sleep 5
done
/etc/init.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 2"
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 2"
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 2"
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 2"
fi
if [ -n "$droute" ]; then
ip route del default
defroute="ip route add default equalize $droute"
`$defroute`
fi
ip route flush cache