[CentOS] Choosing network interface to send traffic through

Emmanuel Noobadmin
2011-04-12T09:56:24Z

I've got a server that initially was connected to a static WAN
connection via eth0. Now I've added a second NIC eth1 connected to a
local network switch with the intention of using it as a backup remote
access connection via a dynamic ADSL connection.

The problem now is getting the IP address of the dynamic ADSL connection.

I've written a script that updates another server with the current IP
address in order to ssh in which was used on my own home server also
running Centos 5. But in the case of two NICs, I cannot find a way to
make the outbound traffic of the script use eth1 instead of the
default gateway on eth0.

There are instructions on using iproute to ensure that a connection
coming in from eth1 will work properly. But this only appears to work
for when the connection is initiated externally through eth1.

The only way I found that might work is adding a static route, but
then this assumes that I'll always be connecting from the same
external IP.

Does anybody know if what I'm trying to achieve is possible?