多出口断线自动切换
作者:
lotosbin | 来源:发表于
2015-09-19 12:21 被阅读55次#!/bin/sh
# 检查网络连接并设置TUNDEV
TUNDEV=""
VPN_CONN=`ifconfig | grep 'pptp-vpn '`
VPN_CONN1=`ifconfig | grep 'pptp-vpn1 '`
VPN_CONN2=`ifconfig | grep 'pptp-vpn2 '`
if [ ! -z "$VPN_CONN" ]; then
TUNDEV="pptp-vpn"
elif [ ! -z "$VPN_CONN1" ]; then
TUNDEV="pptp-vpn1"
elif [ ! -z "$VPN_CONN2" ]; then
TUNDEV="pptp-vpn2"
fi
#根据在线设备,设置路由
if [ "$TUNDEV" == "" ]; then
ip rule del table vpn
else
ip route del 8.8.8.8
ip route flush table vpn 2>/dev/null
ip rule del table vpn 2>/dev/null
ip route add 8.8.8.8 dev $TUNDEV
ip rule add fwmark 999 table vpn
ip route add default dev $TUNDEV table vpn
fi
本文标题:多出口断线自动切换
本文链接:https://www.haomeiwen.com/subject/jwwbcttx.html
网友评论