Static route configuration?

Issues related to configuring your network
Post Reply
antonovich
Posts: 11
Joined: 2007/08/30 18:48:23

Static route configuration?

Post by antonovich » 2011/10/01 13:20:48

Hi all,
Networking is not my forté, so any help appreciated! I have the following requirement:

Several ethernet ports, each with one or more IPs from different networks, so for example

eth0 - 172.16.0.1/255.255.0.0
eth0:0 - 172.16.0.2/255.255.0.0

eth1 - 1.1.1.1/255.255.255.0
eth1:0 - 1.1.1.2/255.255.255.0

eth2 - 2.1.1.1/255.255.255.0
eth2:0 - 2.1.1.2/255.255.255.0

and so on. In order to simplify matters I have reduced to the following to try and get things working.

eth0 - 172.16.0.1/255.255.0.0
eth1 - 1.1.1.1/255.255.255.0

So I have some (SMTP) software that can chose which IP it presents to the world for different tasks. There are therefore different gateways I need to use, and so I need to be able to route via 1.1.1.254 when my software wants to go out with 1.1.1.1 (and so on for 2.1.1.1, etc.), and via 172.16.0.254 for everything else. While this is not possible using default software on Windows, as far as I understand, this is indeed possible on Linux (and CentOS 6 in particular)!
I may not understand things correctly but afaict, the correct doc page is this:
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s1-networkscripts-static-routes.html
I have tried pretty much everything, and unfortunately nothing works. Neither of the config formats seems to work for me. This is indeed possible on CentOS 6 right?
I can get to the following situation (only when issuing # route... commands, using the config files mentioned in the docs doesn't work for me):

# route -n
1.1.1.0 1.1.1.254 255.255.255.0 UG 0 0 0 eth0
1.1.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
172.16.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
0.0.0.0 172.16.0.254 0.0.0.0 UG 0 0 0 eth1

This is what I should have, right? Should this be working?
Any help most appreciated!
Thanks
Anton

antonovich
Posts: 11
Joined: 2007/08/30 18:48:23

Re: Static route configuration?

Post by antonovich » 2011/10/01 19:44:17

I was looking in the wrong place. So yes, it is definitely possible.
See
http://www.generationip.com/documentation/network-documentation/93-howto-setup-multiple-default-gateway-on-linux
http://kindlund.wordpress.com/2007/11/19/configuring-multiple-default-routes-in-linux/
or
http://www.linuxhorizon.ro/iproute2.html

For other noobs out there - the iproute installed by default with Centos 6 is this famous iproute2, so you already have everything you need.
A++

Post Reply