- eht0 - LAN
eth1 - WAN
eth2 -zapasowy WAN
Kiedy pada połączenie z eth1 to automatycznie przełącza się na eth2.
W FreeBSD jest coś takiego jak protokół CARP.
Jest możliwe zrobić coś takiego na Linuksie?
Kod: Zaznacz cały
The network status script
#!/usr/bin/perl
# this script must be run from cron
# defines
$ping1 = "192.168.10.5";
$ping2 = "10.0.0.28";
$admin = "admin";
$netdev = "eth0";
$msgbody = "I think the network is down!";
$msgsub = "Network Down!";
sub pingtest($$) {
my ($ping) = @_;
system(sprintf("ping -q -I %s -c 1 %s>/dev/null", $netdev, $ping));
$retcode = $? >> 8;
# ping returns 1 if unable to connect
return $retcode;
}
$test1 = &pingtest($ping1);
if ($test1 eq "1") {
$test2 = &pingtest($ping2);
if ($test2 eq "1") {
print("Shutting down $netdev...\n");
system(sprintf("ifdown %s", $netdev));
print("Bringing up $netdev...\n");
system(sprintf("ifup %s", $netdev));
$rtest1 = &pingtest($ping1);
if ($rtest1 eq "1") {
$rtest2 = &pingtest($ping2);
if ($rtest2 eq "1") {
system(sprintf("echo \"%s\"|/bin/mail -s \"%s\" %s", $msgbody,
$msgsub, $admin));
exit(1);
}
}
}
}
exit(0);