sedlo |
Subversion Repositories: |
Rev 13 | Rev 14 | |
---|---|---|
Line 1... | Line 1... | |
#!/bin/bash |
#!/bin/bash | |
# author : Petr Simandl www.simandl.cz |
# author : Petr Simandl www.simandl.cz | |
# release date : 08/09/2006 |
# release date : 20/10/2006 | |
# name : sedlo |
# name : sedlo | |
# description : dynamic side routing tables tool |
# description : dynamic side routing tables tool | |
# license : GPL |
# license : GPL | |
|
| |
sl_version="0.0.4pre4" |
sl_version="0.0.4pre5" | |
|
| |
PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin |
PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin | |
|
| |
sl_nmcnf="sedlo.conf" |
sl_nmcnf="sedlo.conf" | |
sl_sedlocnf="/etc/$sl_nmcnf" |
sl_sedlocnf="/etc/$sl_nmcnf" | |
Line 143... | Line 143... | |
for sl_igw in $sl_igws |
for sl_igw in $sl_igws | |
do |
do | |
sl_igwn=`echo $sl_igw | $sl_awkcmd -F '*' '{print $1}'` |
sl_igwn=`echo $sl_igw | $sl_awkcmd -F '*' '{print $1}'` | |
sl_igwip=`echo $sl_igw | $sl_awkcmd -F '*' '{print $2}'` |
sl_igwip=`echo $sl_igw | $sl_awkcmd -F '*' '{print $2}'` | |
sl_igwtype=`echo $sl_igw | $sl_awkcmd -F '*' '{print $3}'` |
sl_igwtype=`echo $sl_igw | $sl_awkcmd -F '*' '{print $3}'` | |
sl_igwgt=`$sl_ipcmd ro ls | $sl_grepcmd "^$sl_igwip " | $sl_awkcmd '{print $3}'` |
#oprava falesneho routovani na lokalni iface - pokud jsme lokalni igw tak se nema najit ip | |
#protoze cesta dal neni - jsme totiz uz na lokalnim iface | ||
sl_igwgt=`$sl_ipcmd ro ls | $sl_grepcmd -v "proto kernel" | $sl_grepcmd "^$sl_igwip " | $sl_awkcmd '{print $3}'` | ||
|
| |
# equal cost multipath detection - just first IP is taken as way to igw |
# equal cost multipath detection - just first IP is taken as way to igw | |
if [ "$sl_igwgt x" = "zebra x" ] |
if [ "$sl_igwgt x" = "zebra x" ] | |
then |
then | |
sl_igwgt=`$sl_ipcmd ro ls | $sl_grepcmd -A 1 "^$sl_igwip " | $sl_grepcmd "nexthop" | $sl_awkcmd '{print $3}'` |
sl_igwgt=`$sl_ipcmd ro ls | $sl_grepcmd -A 1 "^$sl_igwip " | $sl_grepcmd "nexthop" | $sl_awkcmd '{print $3}'` | |
Line 156... | Line 158... | |
#if myigw then fill table for local gateway with single ip from config |
#if myigw then fill table for local gateway with single ip from config | |
if [ "$sl_igwtype x" = "myigw x" ] |
if [ "$sl_igwtype x" = "myigw x" ] | |
then |
then | |
sl_igwgt=$sl_igwip |
sl_igwgt=$sl_igwip | |
fi |
fi | |
|
||
#testing if the igw has not a route in global routing table |
#testing if the igw has not a route in global routing table | |
if [ "$sl_igwgt x" = " x" ] |
if [ "$sl_igwgt x" = " x" ] | |
then |
then | |
if [ $scm_info -gt 1 ]; then echo "Route not found for igw $sl_igwn" ; fi |
if [ $scm_info -gt 1 ]; then echo "Route not found for igw $sl_igwn" ; fi | |
sl_myigw=`cat $sl_sedlocnf | $sl_grepcmd "^myigw" | $sl_grepcmd $sl_igwn | $sl_awkcmd '{print $3}'` |
sl_myigw=`cat $sl_sedlocnf | $sl_grepcmd "^myigw" | $sl_grepcmd $sl_igwn | $sl_awkcmd '{print $3}'` | |
Line 204... | Line 205... | |
if [ "$sl_igwogt x" = "$sl_igwgt x" ] |
if [ "$sl_igwogt x" = "$sl_igwgt x" ] | |
then |
then | |
if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn will not be changed and default is $sl_igwgt" ; fi |
if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn will not be changed and default is $sl_igwgt" ; fi | |
else |
else | |
#the new default is different so we will flush the table, fill new default |
#the new default is different so we will flush the table, fill new default | |
if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn will be rewritten to default $sl_igwgt" ; fi |
if [ $scm_info -gt 1 ]; then echo "Table $sl_igwn will be $sl_igwogt rewritten to default $sl_igwgt" ; fi | |
#flushing old default route in the table |
#flushing old default route in the table | |
$sl_ipcmd ro fl ta $sl_igwn |
$sl_ipcmd ro fl ta $sl_igwn | |
#filling new default |
#filling new default | |
$sl_ipcmd ro add 0.0.0.0/1 via $sl_igwgt ta $sl_igwn |
$sl_ipcmd ro add 0.0.0.0/1 via $sl_igwgt ta $sl_igwn | |
$sl_ipcmd ro add 128.0.0.0/1 via $sl_igwgt ta $sl_igwn |
$sl_ipcmd ro add 128.0.0.0/1 via $sl_igwgt ta $sl_igwn |