I have a requirement where I have to connect to multiple devices connected to different routers with a same switch.

Linux: Centos 6.5

Switch: Tp link router as switch

Router1: xxx.xxx.1.101

Router2: xxx.xxx.2.102

  1. Got LAN connections from switch to 2 routers and Linux.
  2. Connected devices to router1 and router2.
  3. Now my requirement is to ssh from my linux to devices connected to those routers.

I'm very new to Networking/linux. Not sure how to connect or SSH from my linux to device connected to those routers. Please help and Thanks in advance.

Drawing for my requirement

I want the devices to be connected to different networks and should be able to ssh from Linux so I may not bring them to same subnet. I kind of doing research on static routing and tried few things adding multiple gateways in my eth files but none of them worked.

  • Router gateways Router1: xxx.xxx.1.1 Router2: xxx.xxx.2.1 – vikki Sep 5 at 8:55
  • 1
    Have you a diagram of what you have setup? IP addresses/gateways and routes you have setup should be included – Ross Sep 5 at 9:36

Very partial answer:

If you learned networking from configuring home routers via the UI, then you unfortunately have a completely wrong idea about the basics.

The basics are:

  1. Draw a diagram.
  2. Think in subnets.
  3. You need routes on all involved hosts, unless you can set a default route.
  4. You can announce routes (both default and custom) via DHCP.

If the requirement you gave is complete (use three routers to connect different devices), and you didn't omit some important additional constraints (like "two of the routers are already connected to the internet, via different ISPs"), then the simplest solution is to configure all three routers as a simple switch (no NAT), connect them together in any way you please, and maybe pick one of them to run DHCP (so you have a single subnet, e.g. 192.168.5.*/24).

If that doesn't work because of extra conditions, please edit your question.


You can give your Linux host in /etc/network/interfaces a virtual 3 IP address ( with same adresse of devices eth01 : x.x.1.x eth02: x.x.2.x Eth03: x.x.3.x ) to be with same subnet with devices and you will able to ping and ssh-login to others devices. If you can ping the device , you can login ssh with this command ssh username@addresIpOfDevice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.