sedlo |
Subversion Repositories: |
Rev 8 | Rev 9 | |
---|---|---|
Line 3... | Line 3... | |
# release date : 07/09/2004 |
# release date : 07/09/2004 | |
# name : sedlo |
# name : sedlo | |
# description : dynamic side routing tables tool |
# description : dynamic side routing tables tool | |
# license : GPL |
# license : GPL | |
|
| |
#changelog |
sl_version="0.0.3pre9" | |
# - ip ro fl ca |
||
# - myigw |
||
|
||
sl_version="0.0.3pre7" |
||
|
| |
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 46... | Line 42... | |
else |
else | |
echo "$sl_rttab not found" |
echo "$sl_rttab not found" | |
exit 1 |
exit 1 | |
fi |
fi | |
|
| |
sl_murlcfg=`cat $sl_sedlocnf | grep "^mcnf" | uniq | awk '{print $2}'` |
sl_murlcfg=`cat $sl_sedlocnf | grep "^mcnf" | uniq | awk '{print $2" "$3" "$4}'` | |
|
| |
###################################################################### |
###################################################################### | |
s_maru() |
s_maru() | |
{ |
{ | |
if [ $scm_info -gt 0 ]; then echo "Managing rules" ; fi |
if [ $scm_info -gt 0 ]; then echo "Managing rules" ; fi | |
Line 129... | Line 125... | |
###################################################################### |
###################################################################### | |
s_filltables() |
s_filltables() | |
{ |
{ | |
if [ $scm_info -gt 0 ]; then echo "Filling tables" ; fi |
if [ $scm_info -gt 0 ]; then echo "Filling tables" ; fi | |
|
| |
sl_igws=`$sl_catcmd $sl_sedlocache/$sl_nmcnf | $sl_grepcmd "^igw" | $sl_awkcmd '{print $3"*"$2}'` |
sl_igws=`$sl_catcmd $sl_sedlocache/$sl_nmcnf | $sl_grepcmd -E "^igw|^myigw" | $sl_awkcmd '{print $3"*"$2"*"$1}'` | |
|
| |
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_igwgt=`$sl_ipcmd ro ls | $sl_grepcmd "^$sl_igwip " | $sl_awkcmd '{print $3}'` |
sl_igwgt=`$sl_ipcmd ro ls | $sl_grepcmd "^$sl_igwip " | $sl_awkcmd '{print $3}'` | |
|
| |
# equal cost multipath detection - just first is taken |
# 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}'` | |
fi | ||
| ||
#if myigw then fill table for local gateway with single ip from config | ||
if [ "$sl_igwtype x" = "myigw x" ] | ||
then | ||
sl_igwgt=$sl_igwip | ||
fi |
fi | |
|
| |
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 - leaving table as is" ; fi |
if [ $scm_info -gt 1 ]; then echo "Route not found for igw $sl_igwn - leaving table as is" ; fi | |
Line 154... | Line 157... | |
then |
then | |
$sl_ipcmd ro fl ta $sl_igwn |
$sl_ipcmd ro fl ta $sl_igwn | |
fi |
fi | |
$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 | |
if [ $scm_info -gt 1 ]; then echo "Table filled for igw $sl_igwn" ; fi |
if [ "$sl_igwtype x" = "myigw x" ] | |
then | ||
if [ $scm_info -gt 1 ]; then echo "Table filled for myigw $sl_igwn" ; fi | ||
else | ||
if [ $scm_info -gt 1 ]; then echo "Table filled for igw $sl_igwn" ; fi | ||
fi | ||
fi |
fi | |
done |
done | |
|
| |
#this should make faster applying of new routing tables |
#this should make faster applying of new routing tables | |
$sl_ipcmd ro flush cache |
$sl_ipcmd ro flush cache | |
Line 167... | Line 175... | |
|
| |
###################################################################### |
###################################################################### | |
s_mktables() |
s_mktables() | |
{ |
{ | |
if [ $scm_info -gt 0 ]; then echo "Creating tables " ; fi |
if [ $scm_info -gt 0 ]; then echo "Creating tables " ; fi | |
sl_igws=`$sl_catcmd $sl_sedlocache/$sl_nmcnf | $sl_grepcmd "^igw" | $sl_awkcmd '{print $3}'` |
sl_igws=`$sl_catcmd $sl_sedlocache/$sl_nmcnf | $sl_grepcmd -E "^igw|^myigw" | $sl_awkcmd '{print $3}'` | |
for sl_igw in $sl_igws |
for sl_igw in $sl_igws | |
do |
do | |
sl_igwrttb=`$sl_catcmd $sl_rttab | $sl_awkcmd '{print $2}' | $sl_grepcmd $sl_igw ` |
sl_igwrttb=`$sl_catcmd $sl_rttab | $sl_awkcmd '{print $2}' | $sl_grepcmd $sl_igw ` | |
if [ "$sl_igwrttb x" = " x" ] |
if [ "$sl_igwrttb x" = " x" ] | |
then |
then | |
Line 190... | Line 198... | |
sl_cnt=$(($sl_cnt - 1 )) |
sl_cnt=$(($sl_cnt - 1 )) | |
done |
done | |
else |
else | |
if [ $scm_info -gt 1 ]; then echo "Table found for $sl_igw no action taken" ; fi |
if [ $scm_info -gt 1 ]; then echo "Table found for $sl_igw no action taken" ; fi | |
fi |
fi | |
|
||
done |
done | |
| ||
} # s_mktables |
} # s_mktables | |
|
| |
###################################################################### |
###################################################################### | |
s_getcfg() |
s_getcfg() | |
{ |
{ | |
Line 243... | Line 251... | |
} # s_version |
} # s_version | |
|
| |
###################################################################### |
###################################################################### | |
s_report() |
s_report() | |
{ |
{ | |
echo Content-type: text/html | ||
echo | ||
echo "Sedlo na routeru `hostname`" | ||
echo "<pre>" | ||
echo "##### SEDLO #####" |
echo "##### SEDLO #####" | |
echo "date : `date`" |
echo "date : `date`" | |
echo "version : $sl_version" |
echo "version : $sl_version" | |
echo "local_config : $sl_sedlocnf" |
echo "local_config : $sl_sedlocnf" | |
echo "main_config : $sl_murlcfg" |
echo "main_config : <a href=\"$sl_murlcfg\">$sl_murlcfg</a>" | |
echo "last update : `cat $sl_sedlocache/last_getcnf.txt`" |
echo "last update : `cat $sl_sedlocache/last_getcnf.txt`" | |
echo "##### TABLES #####" |
echo "##### TABLES #####" | |
cat $sl_rttab |
cat $sl_rttab | |
echo "##### RULES #####" |
echo ; echo "##### DEFAULT ROUTES IN TABLES #####" | |
$sl_ipcmd ru ls |
$sl_ipcmd ro ls ta all | $sl_grepcmd table | $sl_grepcmd -v local | $sl_trcmd " " "\t" | |
echo ; echo "##### RULES FOR IPS #####" | ||
$sl_ipcmd ru ls | $sl_trcmd " " "\t" | ||
echo "</pre>" | ||
} # s_report |
} # s_report | |
| ||
| ||
|
| |
###################################################################### |
###################################################################### | |
s_help() |
s_help() | |
{ |
{ | |
echo Pouziti: sedlo [param] |
echo Pouziti: sedlo [param] |