Enviado em 18/12/2011 - 21:39h
Boa noite a todos.#!/bin/sh
# eth0 -> Rede interna (192.168.0.1/24)
# ppp0 -> Modem 1 - rt_tables -> Tabela 202 claro1
# ppp1 -> Modem 2 - rt_tables -> Tabela 203 claro2
# Variaveis - Pego o Endereço IP Dinânimo, a Mascara e o Getw das duas conexões
ppp0_addr=`ifconfig ppp0 | grep inet | cut -d : -f 2 | cut -dP -f 1`
ppp0_mask=`ifconfig ppp0 | grep inet | cut -d : -f 4 | cut -dP -f 1`
ppp0_net=`ifconfig ppp0 | grep inet | cut -d ":" -f 3 | tr -d "A-Z, a-z,-"`
ppp1_addr=`ifconfig ppp1 | grep inet | cut -d : -f 2 | cut -dP -f 1`
ppp1_mask=`ifconfig ppp1 | grep inet | cut -d : -f 4 | cut -dP -f 1`
ppp1_net=`ifconfig ppp1 | grep inet | cut -d ":" -f 3 | tr -d "A-Z, a-z,-"`
# Zerando TabelasClaro1 e Claro 2 e Main
ip route flush table claro1
ip route flush table claro2
ip route flush table main
# Claro 1
echo -n " Setando Tabela claro 1"
ip route add $ppp0_mask dev ppp0 src $ppp0_addr table claro1
ip route add default via $ppp0_addr dev ppp0 table claro1
echo " [OK]"
# Claro 2
echo -n " Setando Tabela claro 2"
ip route add $ppp1_mask dev ppp1 src $ppp1_addr table claro2
ip route add default via $ppp1_addr dev ppp1 table claro2
echo " [OK]"
# Regras das Tabelas
echo -n " Criando Regras para tabelas Claro "
ip rule add from $ppp0_net table claro1
ip rule add from $ppp1_net table claro2
echo " [OK]"
#Criando rotas na tabela main
echo -n " Setando Rotas na Tabela Principal "
ip route add $ppp0_net dev ppp0 src $ppp0_addr
ip route add $ppp1_net dev ppp1 src $ppp1_addr
ip route add 192.168.0.0/24 dev eth0 src 192.168.0.1
ip route add 127.0.0.0/8 via 127.0.0.1 dev lo
ip route add default nexthop via $ppp0_net dev ppp0 weight 2 nexthop via $ppp1_net dev ppp1 weight 1
echo " [OK]"
# flush no roteamento
echo -n " Flush no Roteamento "
ip route flush cache
echo " [OK]"
Desktop Linux ganha fôlego enquanto distros refinam experiência e segurança
Wayland em alta, IA em debate e novos ventos para distros e devices
Qt 6.10 e Python 3.14 puxam o ritmo do software livre nesta quarta
Atualizações de Apps, Desktop e Kernel agitam o ecossistema Linux nesta terça-feira
Como mudar o nome de dispositivos Bluetooth via linha de comando
Adicionando o repositório backports no Debian 13 Trixie