Redhat – How to configure 2 NICs with 2 different gateways

connectionnetworkingnicredhat

I have a server with 3 NICs running RHEL6.

eth0 is connected to the intranet.

eth1 is connected to the Operations and Maintenance Network

eth2 is connected to an automated backup network (doesnt need a default gateway)

NICs

I defined my default gateway in /etc/sysconfig/network and I have connectivity. The problem is that I have to define another default gateway for eth1 (which is different from eth0). I tried assigning the gateway directly for eth0/eth1 (and adding them into its respective ifcfg-ethX file) but I lost connectivity to the server. And here its easier to handshake the President than to get physical access to the server farm.

How can I do this? Preferably without losing connectivity.

Best Answer

A "default" gateway is just one that is used when there isn't a more specific route defined. You don't want to have a default route on two different interfaces (unless you're doing it for redundancy). What you want is to have a default route on your "main" interface that most of the traffic uses and then you want to create a persistent static route for each other interface for the subnets that they connect to.