Emmanuel Noobadmin
2011-Apr-12 09:56 UTC
[CentOS] Choosing network interface to send traffic through
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?
Ljubomir Ljubojevic
2011-Apr-12 12:04 UTC
[CentOS] Choosing network interface to send traffic through
Emmanuel Noobadmin wrote:> 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?You need policy routing. And it is possible. My suggestion is to use shorewall (http://www.shorewall.net/), there are rpm's for download, and use it's "Mult-ISP" feature (http://www.shorewall.net/MultiISP.html). Webmin can be of some help with setting it, it even supports manual edit of config files (you will need it for part of the setup.) Ljubomir