亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1706 | 回復: 0
打印 上一主題 下一主題

[網(wǎng)絡相關(guān)] CENTOS下面多外線路由策略應用測試腳本! [復制鏈接]

論壇徽章:
2
羊年新春福章
日期:2015-04-27 16:56:53射手座
日期:2015-04-27 16:58:18
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2015-05-22 16:14 |只看該作者 |倒序瀏覽
[ 本帖最后由 古丁高手 于 2015-05-22 16:34 編輯 ]

環(huán)境:
OS:CENTOS6.5
版本:x64
多外線:電信、聯(lián)通、移動

寫了個粗劣的腳本,添加策略路由、默認網(wǎng)關(guān)和明細路由條目。大神可以給點意見修改一下。
#!/bin/bash
#################################
#autor:xwy                                          #
#date:v1.0                                               #               
#date:2015.05.22                                                #
#################################
#1.添加默認網(wǎng)關(guān);
if [ -f /etc/iproute2/rt_tables ] ;then

        echo "150        EDU" >>/etc/iproute2/rt_tables
        echo "160        YD" >>/etc/iproute2/rt_tables
        echo "170        LT" >>/etc/iproute2/rt_tables
        echo "180        DX" >>/etc/iproute2/rt_tables
        echo "190        CK" >>/etc/iproute2/rt_tables
else
        echo '/etc/iproute2/rt_tables is not exit! warning!'
        exit 1
fi
sleep 1
#2.查出有多少張網(wǎng)卡
#網(wǎng)卡張數(shù):ifconfig |awk '{print $1}'|grep -E 'eth|em'
#網(wǎng)卡ip地址:ip=`ifconfig a | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'`
#設(shè)置array_eth和arry_ip數(shù)組代表網(wǎng)卡和對應的IP
echo '###########################################'
echo "The localhost Apapter and IP is as flow:"
declare -a array_eth array_ip
i=1
for eth in `ifconfig |awk '{print $1}'|grep -E 'eth|em'|cat`
do       
        array_eth[i]="$eth"
        ip=`ifconfig $eth | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'`
        array_ip[i]="$ip"
        echo "NO.$i        ${array_eth[i]}        ${array_ip[i]}"

        i=`expr $i + 1`
done
echo '###########################################'
#3.用戶交付
j=1
while [ $j -le ${#array_eth[@]} ]
do
echo ""
echo '###########################################'
echo 'Be carefule to confirm the flowing:'
echo "${array_eth[$j]}        ${array_ip[$j]}"
echo "###########################################"
echo  'This eth line is: DX/LT/YD/CK? Please input:'
read sp
case $sp in
        DX) echo 'Please input DX Gateway:'
        read dx
        ip route flush table DX
        ip route add default via $dx table DX
        ip rule add from ${array_ip[$j]}/32 table DX
        if [ -f ./dx.ips ];then
                for ip1 in `cat ./dx.ips`
                do
                        echo $ip1 via $dx >> /etc/sysconfig/network-scripts/route-${array_eth[$j]}
                done
        else
                echo 'dx.ips file is not exit!'
                exit 1
        fi
        ping -I${array_eth[$j]} baidu.com -c 4
        if [ $? -ne 0 ];then
                echo "Can not access Internet from ${array_eth[$j]} please check it now!"       
                exit 1
        else
                echo 'The DX ip route input is OK!'
        fi
        sleep 1
        ;;
        LT) echo echo 'Please input LT Gateway:'
        read lt
        ip route flush table LT
        ip route add default via $lt table LT
        ip rule add from ${array_ip[$j]}/32 table DX
        if [ -f ./lt.ips ];then
                for ip2 in `cat ./lt.ips`
                do
                        echo $ip2 via $lt >> /etc/sysconfig/network-scripts/route-${array_eth[$j]}
                done
        else
                echo 'lt.ips file is not exit!'
                exit 1
        fi
        ping -I${array_eth[$j]} baidu.com -c 4
        if [ $? -ne 0 ];then
                echo "Can not access Internet from ${array_eth[$j]} please check it now!"
                exit 1
        else
                echo 'The LT ip route input is OK!'
        fi
        sleep 1
        ;;
        YD) echo "Please input YD Gateway:"
        read yd
        ip route flush table YD
        ip route add default via $yd table YD
        ip rule add from ${array_ip[$j]}/32 table YD
        if [ -f ./yd.ips ];then
                for ip3 in `cat ./yd.ips`
                do
                        echo $ip3 via $yd >> /etc/sysconfig/network-scripts/route-${array_eth[$j]}
                done
        else
                echo 'yd.ips file is not exit!'
                exit 1
        fi
        echo 'The YD ip route input is OK!'
        sleep 1
        ;;
        CK) echo "Please input CK Gateway:"
        read ck
        ip route flush table CK
        ip route add default via $ck table CK
        ip rule add from ${array_ip[$j]}/32 table CK
        if [ -f ./CK.ips ];then
                for ip4 in `cat ./lt.ips`
                do
                        echo $ip4 via $ck >> /etc/sysconfig/network-scripts/route-${array_eth[$j]}
                done
        else
                echo 'ck.ips file is not exit!'
                exit 1
        fi
        ping -I${array_eth[$j]} baidu.com -c 4
        if [ $? -ne 0 ];then
                echo "Can not access Internet from ${array_eth[$j]} please check it now!"
                exit 1
        else
                echo 'The CK ip route input is OK!'
        fi
        sleep 1
        ;;
        *) echo "usage:input[DX|LT|YD|CK]"
        exit 1
        ;;
esac
j=`expr $j + 1`
done

service network restart
if [ $? -ne 0 ];then
echo 'The script is running wrong,please check it agin!'
exit 1
else
echo 'ALL the ip route input setting is OK!'
fi
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP