Multple IPs on FC2, route table sample (and the LARTC)
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.
> 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
> 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.
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.
So this is how I've settled out my configuration, flames to /dev/null, constructive criticism welcome.
From LARTC
[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.