ไฟล์ /etc/ppp/ip-up.d/0route (ppp101 = Games , ppp102 + ppp103 = WEB)
#!/bin/bash
WAN1=0
WAN2=0
WAN3=0
ppp101=`/sbin/ifconfig -a | grep "ppp101"`
if [ -n "$ppp101" ]; then
# echo "ppp101 is up"
WAN1=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
fi
ppp102=`/sbin/ifconfig -a | grep "ppp102"`
if [ -n "$ppp102" ]; then
# echo "ppp102 is up"
WAN2=1
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
fi
ppp103=`/sbin/ifconfig -a | grep "ppp103"`
if [ -n "$ppp103" ]; then
# echo "ppp103 is up"
WAN3=1
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
fi
LinkStatus=$WAN1$WAN2$WAN3
if [ $LinkStatus -eq 111 ]; then
ip route del default
ip route del table 101 default
ip route del table 102 default
ip route del table 103 default
ip route del table 250 default
ip route add default equalize nexthop dev ppp102 weight 4 nexthop dev ppp103 weight 4
ip route add table 101 default dev ppp101
ip route add table 102 default dev ppp102
ip route add table 103 default dev ppp103
ip route add table 250 default equalize nexthop dev ppp102 weight 4 nexthop dev ppp103 weight 4
fi
if [ $LinkStatus -eq 011 ]; then
ip route del default
ip route del table 101 default
ip route del table 102 default
ip route del table 103 default
ip route del table 250 default
ip route add default dev ppp103
ip route add table 101 default dev ppp102
ip route add table 102 default dev ppp103
ip route add table 103 default dev ppp103
ip route add table 250 default dev ppp103
fi
if [ $LinkStatus -eq 101 ]; then
ip route del default
ip route del table 101 default
ip route del table 102 default
ip route del table 103 default
ip route del table 250 default
ip route add default dev ppp103
ip route add table 101 default dev ppp101
ip route add table 102 default dev ppp103
ip route add table 103 default dev ppp103
ip route add table 250 default dev ppp103
fi
if [ $LinkStatus -eq 110 ]; then
ip route del default
ip route del table 101 default
ip route del table 102 default
ip route del table 103 default
ip route del table 250 default
ip route add default dev ppp 102
ip route add table 101 default dev ppp101
ip route add table 102 default dev ppp102
ip route add table 103 default dev ppp102
ip route add table 250 default dev ppp102
fi
if [ $LinkStatus -eq 100 ]; then
ip route del default
ip route del table 101 default
ip route del table 102 default
ip route del table 103 default
ip route del table 250 default
ip route add default dev ppp101
ip route add table 101 default dev ppp101
ip route add table 102 default dev ppp101
ip route add table 103 default dev ppp101
ip route add table 250 default dev ppp101
fi
if [ $LinkStatus -eq 010 ]; then
ip route del default
ip route del table 101 default
ip route del table 102 default
ip route del table 103 default
ip route del table 250 default
ip route add default dev ppp 102
ip route add table 101 default dev ppp102
ip route add table 102 default dev ppp102
ip route add table 103 default dev ppp102
ip route add table 250 default dev ppp102
fi
if [ $LinkStatus -eq 001 ]; then
ip route del default
ip route del table 101 default
ip route del table 102 default
ip route del table 103 default
ip route del table 250 default
ip route add default dev ppp 103
ip route add table 101 default dev ppp103
ip route add table 102 default dev ppp103
ip route add table 103 default dev ppp103
ip route add table 250 default dev ppp103
fi
if [ $LinkStatus -eq 000 ]; then
ip route del default
ip route del table 101 default
ip route del table 102 default
ip route del table 103 default
ip route del table 250 default
fi
ip route flush cache
ไม่มีความคิดเห็น:
แสดงความคิดเห็น