Multple IPs on FC2, route table sample (and the LARTC)

Back from IRC, now just looking for the confidence that I did it right. :) A lot of the samples and posts on the board look geared toward Debian.

I followed the members.cfm notes. Googled. Got it, finally, working…I think. Can anyone provide a sample netstat -r? I have two IPs on different subnets. I have alias one IP to eth0:0. I have added route add default gw 64.x.x.x and route add default gw 70.x.x.x to my /etc/rc.local (because I could not get it work any other way; even FC4 seems conflicted in how this should be done between legacy formats and generally no documentation on the distro way of doing it, but I digress).

My route table looks like this now:

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
64.x.x.0        *               255.255.255.0   U         0 0          0 eth0
70.x.x.0        *               255.255.255.0   U         0 0          0 eth0
169.x.0.0       *               255.255.0.0     U         0 0          0 eth0
default         gateway         0.0.0.0         UG        0 0          0 eth0
default         gateway1        0.0.0.0         UG        0 0          0 eth0

Another view using route:

[user@host ~]$ /sbin/route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
64.x.x.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
70.x.x.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.x.0.0       0.0.0.0         255.255.0.0     U     0      0        0 eth0
0.0.0.0         64.x.x.1        0.0.0.0         UG    0      0        0 eth0
0.0.0.0         70.x.x.1        0.0.0.0         UG    0      0        0 eth0

4 Replies

@javafueled:

I have two IPs on different subnets. I have alias one IP to eth0:0. I have added route add default gw 64.x.x.x and route add default gw 70.x.x.x to my /etc/rc.local (because I could not get it work any other way; even FC4 seems conflicted in how this should be done between legacy formats and generally no documentation on the distro way of doing it, but I digress).

My route table looks like this now:

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
64.x.x.0        *               255.255.255.0   U         0 0          0 eth0
70.x.x.0        *               255.255.255.0   U         0 0          0 eth0
169.x.0.0       *               255.255.0.0     U         0 0          0 eth0
default         gateway         0.0.0.0         UG        0 0          0 eth0
default         gateway1        0.0.0.0         UG        0 0          0 eth0

Not a bad start. Wanted to make sure you understood something.

You can't have two default gateways active at the same time.

Concept of 'default gateway' is: 'if nothing else matches, send packets here'.

There can only be one default gateway active, because if you think about it, 'if nothing else matches' means there can be only ONE remaining match.

Linux allows you to have two default gateways listed because, if the first gateway is completely down, it will attempt to use the next listed default gateway instead. One gateway is active at a time, even though two are listed.

If that is how you intended to use the multiple default gateways, then great. If this was not how you planned it, then you'll need to rethink your goal and arrangement.

What exactly is your goal? Are you doing this as a failover scenario of some sort?

You want to route certain traffic out of a specific interface only? (If so, shouldn't need the default route for diverting a specific subnet through a particular interface.)

I'm afraid I'm not much help with distro-specific stuff like for Debian or FC4, since I'm more familiar with Gentoo. Sorry. :) But networking in general, can give pointers.

> You can't have two default gateways active at the same time.

Concept of 'default gateway' is: 'if nothing else matches, send packets here'.

You know, I thought that too. But the linode documentation implies other. https://www.linode.com/members/netinfo.cfm (login required). The relevant part being:

> You can add these commands to your rc startup script to have the IPs configured at boot time. Or, use your distribution's configuration tools to do it 'the right way'.

If you have IPs in different subnets, make sure to do "route add default gw x.x.x.x" for each Gateway listed in the table above.

So, that's what I did. :) Now, that noted, the problem I'm having is that FC2 (and RHL and FC[1-4] for that matter) have serious documentation and legacy configuration issues, that I'm finding very hard to navigate. It's frustrating to no end. Putting the directives in rc.local was the only way to make it work, because, as Linode notes, "the right way" (for [insert distro]) does not seem to behave at all.

Clearly Debian has the advantage here with it's interface configuration scripts. Those scripts clearly imply that each interface can have a gateway. Supposedly, FC[1-4] can too, but I can't for the life of me get /etc/sysconfig/network-scripts/(route-eth0||route-eth0:0) to load, /etc/init.d/network does not call or source these scripts, and if it supposed to work some particular way, someone show me because its a charlie-foxtrot. But I digress… :)

> If that is how you intended to use the multiple default gateways, then great. If this was not how you planned it, then you'll need to rethink your goal and arrangement.

What exactly is your goal? Are you doing this as a failover scenario of some sort?

You want to route certain traffic out of a specific interface only? (If so, shouldn't need the default route for diverting a specific subnet through a particular interface.)

I believe my goal was the latter, but I believe I really was trying to follow the Linode documentation. :/ My plans include an Apache server with an IP for NameVirtualHosts and an IP for SSL (an IP-based host).

Many thanks for your reply. Maybe you can shed some light on what Linode is trying to say, versus what is implemented in practice.

Learning a lot about Linux routing.

So this is how I've settled out my configuration, flames to /dev/null, constructive criticism welcome.

From LARTC, sect. 4.2.2, "Routing for multiple uplinks/providers: Load Balancing"

[root@host root]# ip route show
64.x.x.0/24 dev eth0  proto kernel  scope link  src 64.x.x.x 
70.x.x.0/24 dev eth0  proto kernel  scope link  src 70.x.x.x
169.254.0.0/16 dev eth0  scope link 
default
        nexthop via 70.x.x.1  dev eth0 weight 1
        nexthop via 64.x.x.1  dev eth0 weight 1

I added this to /etc/rc.local:

__ip route add default scope global \

nexthop via 70.x.x.1 dev eth0 weight 1 \

nexthop via 64.x.x.1 dev eth0 weight 1__

This effectively meets the recommendations of Linode's notes on adding additional IPs without a confusing "second default" route.

I just documented my findings in the linode wiki. Constructive criticism welcome.

Multiple IPs

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct