[CentOS] route question

Ross Walker rswwalker at gmail.com
Mon May 17 14:21:48 UTC 2010


On May 15, 2010, at 7:13 AM, Dominik Zyla <gavroche at gavroche.pl> wrote:

> On Fri, May 14, 2010 at 03:02:04PM -0400, Jerry Geis wrote:
>>>
>>> GATEWAY=74.223.8.177 on /etc/sysconfig/network file ?
>>>
>> Actually I have that in the ifcfg-eth1 and ifcfg-eth2. And this is  
>> hte
>> route I get.
>>
>> DEVICE=eth1
>> ONBOOT=YES
>> BOOTPROTO=static
>> IPADDR=74.223.8.179
>> NETMASK=255.255.255.240
>> GATEWAY=74.223.8.177
>>
>>
>> DEVICE=eth2
>> ONBOOT=Yes
>> BOOTPROTO=static
>> IPADDR=24.123.23.170
>> NETMASK=255.255.255.248
>> GATEWAY=24.123.23.169
>>
>> route -n
>> Kernel IP routing table
>> Destination     Gateway         Genmask         Flags Metric Ref     
>> Use
>> Iface
>> 24.123.23.168   0.0.0.0         255.255.255.248 U     0       
>> 0        0 eth2
>> 74.223.8.176    0.0.0.0         255.255.255.240 U     0       
>> 0        0 eth1
>> 192.168.1.0     0.0.0.0         255.255.255.0   U     0       
>> 0        0 eth0
>> 169.254.0.0     0.0.0.0         255.255.0.0     U     0       
>> 0        0 eth2
>> 0.0.0.0         24.123.23.169   0.0.0.0         UG    0       
>> 0        0 eth2
>>
>>
>> I dont want 74.X traffic going out 24.X network. I want it going back
>> out the 74.X network.
>> How do I setup the ifcfg-eth files so the GW above will route back  
>> out
>> the correct gw?
>
> It won't work. You can't have two default gateways. Init scripts first
> set your gateway via eth1, then parse ifcfg-eth2 (alphabetical) and
> overwrites previous settings.

True, you can have only one gateway of last resort and the OP needs to  
pick which one, but you can do policy based routing in iptables, and  
if reverse NAT is configured I believe incoming connections should  
work as advertised.

There was a thread just recently discussing solutions for this type of  
setup.

-Ross




More information about the CentOS mailing list