[CentOS] outside ssh connection from two different ISP's

Tue Nov 11 16:12:58 UTC 2014
Les Mikesell <lesmikesell at gmail.com>

On Tue, Nov 11, 2014 at 5:53 AM, Steve Clark <sclark at netwolves.com> wrote:
> On 11/10/2014 05:38 PM, Jack Bailey wrote:
>>
>> On 11/10/2014 2:11 PM, Frank Cox wrote:
>>>
>>> I have both cable and dsl service.  The router attached to the cable
>>> service is 192.168.0.1 and the router attached to the dsl service is
>>> 192.168.0.254.  I determine which service my computers communicate through
>>> by setting the gateway assignment to either of those addresses and it just
>>> works.
>>>
>>> I can connect to my computers from the outside by port forwarding from my
>>> routers to the computer that I want to connect to.
>>>
>>> However, the outside ssh connection works only if the computer's gateway
>>> assignment matches the router that I'm connecting to.  I suspect that I have
>>> to set up some sort of routing assignment to tell the computer to reply to
>>> the gateway that the ssh connection request came in on if it doesn't match
>>> the current gateway assignment, but I have no idea how to do that.
>>>
>> I also have two ISPs at home.  I have a Peplink to manage this now, but
>> before that I some commands in rc.local.  I had two networks and two
>> NICs on my workstation.  This used to work on CentOS 6.
>>
>> ##############################
>> # symetric routing           #
>> ##############################
>>
>> NIC1=eth0
>> IP1=192.168.1.6
>> GW1=192.168.1.1
>> NET1=192.168.1.0/24
>>
>> NIC2=eth1
>> IP2=192.168.2.6
>> GW2=192.168.2.1
>> NET2=192.168.2.0/24
>>
>> DEFGW=$GW2
>>
>> cat << EOF > /etc/iproute2/rt_tables
>> #
>> # reserved values
>> #
>> 255     local
>> 254     main
>> 253     default
>> 0       unspec
>> #
>> # local
>> #
>> #1      inr.ruhep
>>
>> # symetric routing
>> 101     T1
>> 102     T2
>> EOF
>>
>> # routing and default gateway for each interface
>> ip route add $NET1 dev $NIC1 src $IP1 table T1
>> ip route add default via $GW1 table T1
>> ip route add $NET2 dev $NIC2 src $IP2 table T2
>> ip route add default via $GW2 table T2
>>
>> # regular routes
>> ip route add $NET1 dev $NIC1 src $IP1
>> ip route add $NET2 dev $NIC2 src $IP2
>>
>> # preference for default route
>> route delete default
>> ip route add default via $DEFGW
>>
>> # rules
>> ip rule add from $IP1 table T1
>> ip rule add from $IP2 table T2
>>
>> # enable routing
>> echo 1 > /proc/sys/net/ipv4/ip_forward
>>
>> Good luck,
>> Jack
>>
>>
> I can verify the above works just fine if all you want to be able to do is
> reach your system from
> outside over either isp..
>

I think that is a different scenario, though.  Since the subnet
addresses are the same for both routers, the OP must only have one
NIC.

-- 
   Les Mikesell
      lesmikesell at gmail.com