[CentOS] Help with routing question.

Wed Feb 18 18:07:49 UTC 2015
Les Mikesell <lesmikesell at gmail.com>

On Wed, Feb 18, 2015 at 11:39 AM, James B. Byrne <byrnejb at harte-lyne.ca> wrote:
>
> We have a host that has multiple IPv4 addresses aliased to eth0.   The
> primary address is 216.185.71.x and the alias is 192.168.6.x.
>
> This host connects to devices on both netblocks without problems.
> Only default routing is used and it looks like this:
>
> #ip route
> 192.168.6.0/24 dev eth0  proto kernel  scope link  src 192.168.6.x
> 216.185.71.0/24 dev eth0  proto kernel  scope link  src 216.185.71.x
> 169.254.0.0/16 dev eth0  scope link  metric 1002
> default via 192.168.6.1 dev eth0  src 192.168.6.x
> default via 216.185.71.1 dev eth0
>
> 1. Why is ssh using the private IP in preference to the public IP when
> connecting to off-site addresses?

Because you have a default route for it.

> 2. How does one configure the routing table on network startup to
> specifically detail the route particular addresses are supposed to
> take?
>

Not exactly sure how routing works with aliases on the same interface
but the first thing I would try is the same as you would use on
different interfaces.  That is, leave the 'GATEWAY=' on your
internet-facing etho, but remove the entry from the private eth0:192.
  Then add a route-eth0:192  file containing the network(s) and
gateway for the private side.   The source address it picks should be
the one appropriate to reach the next-hop router specified in your
routes.

-- 
   Les Mikesell
     lesmikesell at gmail.com