[CentOS] routing using iproute2 nexthop

Bazy bazy84 at gmail.com
Fri Oct 16 10:04:24 UTC 2009


Hello Everyone,

I configured a server for a friend's Internet cafe. He has 2 ISPs.
Here is what I did:

## NAT
-A POSTROUTING -s 10.0.0.0/255.255.255.128 -o eth2 -j SNAT --to-source
82.77.148.83
-A POSTROUTING -s 10.0.0.0/255.255.255.128 -o eth0 -j SNAT --to-source
83.103.190.175

## Removing default routing
/sbin/ip rule add prio 50 table main
/sbin/ip route del default table main

## Default gateway using nexthop
/sbin/ip rule add prio 201 from 82.77.148.83/25 table 201
/sbin/ip route add default via 82.77.148.1 dev eth2 src 82.77.148.83
proto static table 201
/sbin/ip route append prohibit default table 201 metric 1 proto static

/sbin/ip rule add prio 202 from 83.103.190.175/27 table 202
/sbin/ip route add default via 83.103.190.161 dev eth0 src
83.103.190.175 proto static table 202
/sbin/ip route append prohibit default table 202 metric 1 proto static

/sbin/ip rule add prio 222 table 222
/sbin/ip route add default table 222 proto static nexthop via
82.77.148.1 dev eth2 nexthop via 83.103.190.161 dev eth0

## Running ping so kernel is aware if a gateway is down
/bin/ping 82.77.148.1 >/dev/null &
/bin/ping 83.103.190.161 >/dev/null &

My problem is that if the second gateway (83.103.190.161) stops
responding the kernel will not notice and will keep forwarding traffic
to it. Only if I "ifdown" the interface it will see it as down. As you
can see above I run a continuous ping to both gateways. I'm just out
of ideas...

[root at dell ~]# ip route show table 222
default  proto static
        nexthop via 82.77.148.1  dev eth2 weight 1
        nexthop via 83.103.190.161  dev eth0 weight 1 dead


Thanks,
Bazy


More information about the CentOS mailing list