Hi all, i have a problem i have this topology
192.168.1.7 GW 192.168.2.252
link 1 ------------------------------------ link 2
|
|
eth1 PROXY eth0
192.168.1.245 192.168.2.245
The default gw of the PROXY is 192.168.1.7 and the link2 is a
Secondary link that i need to go out to internet!!!! My internal IP of
the network is 192.168.2.0/24
Im using this
#!/bin/bash
#
# Legenda:
# eth0 Link2
# eth1 link1
#
#
# Resetando o Firewall:
echo -n "Resetando regras existentes"
iptables -F
iptables -Z
iptables -X
iptables -t nat -F
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
echo "[OK]"
# OBS: essa regra eh mutuamente excludente com a proxima, a do NAT
# ou seja, escolha uma das duas
echo -n "Habilitando o mascaramento..."
#iptables -t nat -A POSTROUTING -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
echo "[OK]"
# Marcando pacotes
echo -n "Marcando pacotes..."
iptables -A PREROUTING -t mangle -s 192.168.2.0/24 -d 0/0 -j MARK --set-mark 3
echo "[OK]"
# Desabilitando o filtro de pacotes do martian source
echo -n "Desligando rp_filter..."
for eee in /proc/sys/net/ipv4/conf/*/rp_filter; do
echo 0 > $eee
done
echo "[OK]"
# Definindo regras de balanceamento de Link:
echo -n "Balanceando links..."
# link #1
ip route add 192.168.1.0/24 dev eth1 src 192.168.1.245 table link1
#ip route add 192.168.0.0/24 via 192.168.0.1 table link1
ip route add default via 192.168.1.7 table link1
# link Default
ip route add 192.168.2.0/24 dev eth0 src 192.168.2.245 table link
#ip route add 192.168.0.0/24 via 192.168.0.1 table link
ip route add default via 192.168.2.252 table link
# tabela principal de roteamento
ip route add 192.168.1.0/24 dev eth1 src 192.168.1.245
ip route add 192.168.2.0/24 dev eth0 src 192.168.2.245
# setando a rota preferencial
ip route add default via 192.168.1.7
# regras das tabelas
ip rule add from 192.168.1.245 table link1
ip rule add from 192.168.2.245 table link
# balanceamento de link
ip rule add fwmark 3 lookup link prio 3
ip route add default table link nexthop via 192.168.1.7 dev eth1
weight 1 nexthop via 192.168.2.252 dev eth0 weight 1
# flush no roteamento
ip route flush cache
echo "[OK]"
sleep 2
But... if i shutdown the link to ip 192.168.1.7 it didnt re-route to
another gateway 192.168.2.252.
Any clue?
Regards,
--
Fabio S. Silva