Pentru ca un kkt de greseala m-a facut sa muiesc scriptul si am dat paste la 
aceeasi sectiune de mai multe ori, anunta-ma daca vrei scriptul undeva pe o 
pagina web sa il iei de acolo.



On Saturday 09 September 2006 02:00, Samareanu Florin wrote:
> In ordine:
>
> echo "1       retea1" >>/etc/iproute2/rt_tables
> echo "2       retea2" >>/etc/iproute2/rt_tables
> echo "3       retea3" >>/etc/iproute2/rt_tables
>
> ip rule add from ip_retea_1 table retea1
> ip rule add from ip_retea_2 table retea2
> ip rule add from ip_retea_3 table retea4
>
> unde ip_retea_x sunt adresele ip pe care ti le-au dat providerii.
>
>
>
> ip route add default via gw_retea_1 table retea1
> ip route add default via gw_retea_2 table retea2
> ip route add default via gw_retea_3 table retea3
>
>
> si cam atat.
>
>
> PS: e un parametru in kernel la sectiunea networking, ceva cu mark based
> routing. trebuie bifata optiunea si recompilat kernelul. PPS: si nici
> suport pentru mai mult de 1 tabela de routare nu strica (urmand exemplul de
> mai sus ai 4).
>
>
> (asta pentru a doua problema, cea "nu merge situl daca nu e ruta default
> prin provierul X)
>
> pentru prima, copy/paste/modifici dupa gust:
>
>
> l#!/usr/bin/perl
>
> # Run from cron (set with "crontab -e")
> # example: "0-59/2 * * * * /path/to/switchisp" runs this every 2 minutes
>
> # Best IPs to test for general use may be last IPs at ISPs before routing
> out to Net # Best IP to test if a single remote site is most important is
> that site's
>
> # If perl not at /usr/bin/perl change first line to point to it
>
> # Before running install Net::Ping from http://freeware.roobik.com/netping/
> # (untar, cd to directory, "perl Makefile.PL; make; make install")
> # or perl -MCPAN -eshell and install Net::Ping
> # This script is NOT Copyrighted :)
>
> use Net::Ping;
>
> # User settings
> # _____________
>
> $ip     = "/sbin/ip";   # Location of "ip" on system
> $ipt    = "/sbin/iptables"; # Location of "iptables" on system
> $gw1    = "ip1_gw";     # Gateway 1 IP
> $dev1   = "eth1";               # Device (e.g., eth2)
> $tip1   = "ip_test_ping_1";     # Upstream IP to test
> $src1   = "source";     # Source address for outgoing packets
> $wei1   = "1";                  # Weight
>
> $gw2    = "ip_gw_2";     # Gateway 2 IP
> $dev2   = "eth2";               # Device (e.g., eth1)
> $tip2   = "4.79.181.15";    # Upstream IP to test
> $src2   = "127.0.0.5";     # Source address for outgoing packets
> $wei2   = "2";                  # Weight
>
>
> $pings  = "4";                  # Number of pings to send
> $good   = "2";                  # Number of pings that must be good
>
> $tab    = "default";            # Table to set routes in
>
> $logfile = "/var/log/checkroutes.log"; # File to log messages to
>
> # create timestamp for log
> # ________________________
>
> sub TimeStamp {
>
>         # subroutine to create a "nice" looking timestamp
>         # that doesn't rely on the system's 'date' command
>
>         my @days = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
>         my @months =
> ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep', 'Oct','Nov','Dec');
>
>         my ($sec,$min,$hour,$dom,$mon,$year,$wday,$yday,$isd) =
> localtime(time); my $timestamp = sprintf("%3s %3s %02d %4d 
> %02d:%02d:%02d", $days[$wday], $months[$mon], $dom, $year+1900, $hour,
> $min, $sec);
>
>         return $timestamp;
> }
>
> # be sure routes are set via appropriate gateways to test IPs
> # ___________________________________________________________
>
> $checkro = `$ip ro ls`;
> if (!($checkro =~ /$tip1/)) {
>         system ("$ip ro add to $tip1 via $gw1 src $src1");
> }
> if (!($checkro =~ /$tip2/)) {
>         system ("$ip ro add to $tip2 via $gw2 src $src2");
> }
>
> # test if $gw1 and/or $gw2 currently in table $tab
> # ________________________________________________
>
> $checkgw = qx/$ip ro ls /;
>
> if ($checkgw =~ /$gw1/) {
>         $check1 = 1;
> } else {
>         $check1 = 0;
> }
>
> if ($checkgw =~ /$gw2/) {
>         $check2 = 1;
> } else {
>         $check2 = 0;
> }
>
> # ping the test IPs $tip1 and $tip2
>
>         # subroutine to create a "nice" looking timestamp
>         # that doesn't rely on the system's 'date' command
>
>         my @days = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
>         my @months =
> ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep', 'Oct','Nov','Dec');
>
>         my ($sec,$min,$hour,$dom,$mon,$year,$wday,$yday,$isd) =
> localtime(time); my $timestamp = sprintf("%3s %3s %02d %4d 
> %02d:%02d:%02d", $days[$wday], $months[$mon], $dom, $year+1900, $hour,
> $min, $sec);
>
>         return $timestamp;
> }
>
> # be sure routes are set via appropriate gateways to test IPs
> # ___________________________________________________________
>
> $checkro = `$ip ro ls`;
> if (!($checkro =~ /$tip1/)) {
>         system ("$ip ro add to $tip1 via $gw1 src $src1");
> }
> if (!($checkro =~ /$tip2/)) {
>         system ("$ip ro add to $tip2 via $gw2 src $src2");
> }
>
> # test if $gw1 and/or $gw2 currently in table $tab
> # ________________________________________________
>
> $checkgw = qx/$ip ro ls /;
>
> if ($checkgw =~ /$gw1/) {
>         $check1 = 1;
> } else {
>         $check1 = 0;
> }
>
> if ($checkgw =~ /$gw2/) {
>         $check2 = 1;
> } else {
>         $check2 = 0;
> }
>
> # ping the test IPs $tip1 and $tip2
>
>         # subroutine to create a "nice" looking timestamp
>         # that doesn't rely on the system's 'date' command
>
>         my @days = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
>         my @months =
> ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep', 'Oct','Nov','Dec');
>
>         my ($sec,$min,$hour,$dom,$mon,$year,$wday,$yday,$isd) =
> localtime(time); my $timestamp = sprintf("%3s %3s %02d %4d 
> %02d:%02d:%02d", $days[$wday], $months[$mon], $dom, $year+1900, $hour,
> $min, $sec);
>
>         return $timestamp;
> }
>
> # be sure routes are set via appropriate gateways to test IPs
> # ___________________________________________________________
>
> $checkro = `$ip ro ls`;
> if (!($checkro =~ /$tip1/)) {
>         system ("$ip ro add to $tip1 via $gw1 src $src1");
> }
> if (!($checkro =~ /$tip2/)) {
>         system ("$ip ro add to $tip2 via $gw2 src $src2");
> }
>
> # test if $gw1 and/or $gw2 currently in table $tab
> # ________________________________________________
>
> $checkgw = qx/$ip ro ls /;
>
> if ($checkgw =~ /$gw1/) {
>         $check1 = 1;
> } else {
>         $check1 = 0;
> }
>
> if ($checkgw =~ /$gw2/) {
>         $check2 = 1;
> } else {
>         $check2 = 0;
> }
>
> # ping the test IPs $tip1 and $tip2
> # _________________________________
>
> $i=0;
> $p = Net::Ping->new("icmp");
> while ($i < $pings) {
>         if ($p->ping($tip1)) {
>                 $ping1++;
>         }
>         $i++;
> }
> $p->close();
>
> if ($ping1 >= $good) {
>         $live1 = 1;
> } else {
>         $live1 = 0;
> }
>
> $i=0;
> $p = Net::Ping->new("icmp");
> while ($i < $pings) {
>         if ($p->ping($tip2)) {
>                 $ping2++;
>         }
>         $i++;
> }
> $p->close();
>
> if ($ping2 >= $good) {
>         $live2 = 1;
> } else {
>         $live2 = 0;
> }
>
> # If the current default in table $tab does not match the ping results then
> # if only one route's test IP is pingable change the default to that route
> # or if both test IPs are pingable change the default to use both
> # or if neither test IPs are pingable change the default to use both
> # (might as well continue to try them, if we're not going anywhere anyway)
> # _________________________________________________________________________
>
> # add new default route
> # ________________________
>
>         if (($live1 == 1)&&($live2 == 0)) {
>                 system ("/calea/catre/un/script/aleator");
>         } elsif (($live1 == 0)&&($live2 == 1)) {
>                 system ("/calea/catre/alt/script");
>         } else {
>                 system ("/calea/catre/al/treilea/script");
> #               system ("echo OK");
>         }
> # log
> # ___
>
> if (($live1 == 1)&&($live2 == 1)) {
>         $log = "A is UP, B is UP";
> } elsif (($live1 == 0)&&($live2 == 0)) {
>         $log = "A is DOWN, B is DOWN (!!BIG FAT WARNING!!)";
> } elsif (($live1 == 1)&&($live2 == 0)) {
>         $log = "A is UP, B is DOWN";
> } elsif (($live1 == 0)&&($live2 == 1)) {
>         $log = "A is DOWN, B is up";
> }
>
> open(LOG, ">>$logfile");
> print LOG &TimeStamp . " - $log\n";
> close(LOG);
>
>
> Se modifica/adauga chestii in script dupa gust si se ruleaza din cron. easy
> as that.
>
> On Saturday 09 September 2006 01:24, Laurentiu STEFAN wrote:
> > Da nu se poate gasi o solutzie la o problema fara sa se ajunga la
> > discutzii dastea?
> >
> > Eu cu un pic ajutor de la cunoscutzi am facut un programas care face o
> > chestie. Am pus programu aici in cazu in care mai are cineva nevoie de
> > el... am spus se hibe au, unele s-au rezolvat cu ajutor de la voi sau cu
> > ajutor de la alti amici.
> >
> > Acu a mai ramas hiba cu vizibilitatea din internet a tuturor
> > interfetelor.
> >
> > Aici ar fi o solutzie sa declar la RNC toate IP-urile ca NS si programul
> > care ruta sa imi genereze fisierul pentru NS al domeniului in functie de
> > GW-ul sistemului la acel moment si in momentul in care trebuie sa schimbe
> > GW-ul sa schimbe si fisierul respectiv si sa reincarce NS-ul.
> > Problema e ca nu stiu cat de repede se propaga modificarea in cazu asta
> > si daca apare o interogare si nu ii raspunde primele 3 NS-uri declarate
> > la RNC il testeaza si pe al 4-lea? Sau dupa 2-3 erori renuntza si da ca
> > nu exista domeniu?
> >
> > On 9/8/06, Mircea MITU <[EMAIL PROTECTED]> wrote:
> > > On Fri, 2006-09-08 at 12:22 +0300, George-Cristian Bîrzan wrote:
> > > > >       Mai citeste odata mailurile, nu ai nici o legatura.
> > > >
> > > > 1) O DATA, ANALFABETU' PULII!
> > >
> > > Marş si citeste Dicţionarul Ortografic, Ortoepic şi Morfologic al
> > > Limbii Române (DOOM 2). După ce-l termini şi renunţi să mai imiţi
> > > bizoni de 12 ani ce au descoperit dc++, poţi veni să-ţi ceri scuze.
> > >
> > > Mulţumim,
> > > redacţia
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > RLUG mailing list
> > > [email protected]
> > > http://lists.lug.ro/mailman/listinfo/rlug

-- 
Florin Samareanu
IT Consultant
_____  
1st. Sisesti St., Bucharest 1, Romania 
Phone: +4021 269.33.03
Fax:   +4021 233.12.50 
Mobile:+40 744.596.338
 

Email:

[EMAIL PROTECTED] 
www.vectorsoftware.ro

_______________________________________________
RLUG mailing list
[email protected]
http://lists.lug.ro/mailman/listinfo/rlug

Raspunde prin e-mail lui