I have a home network with the standard 192.168.0.xxx available from my DHCP server in my router.

I have a system "X", which has a dual NIC:

  • eno1 is tied to the 192 subnet
  • eno2 is statically defined into a subnet and connected to a RPi
    • X's IP =
    • RPi's IP =

I'd like to be able to ssh from another host, "Y" (on subnet 192), through "X", into the RPi.

I figure I can set up the RPi sshd port number to something different (e.g. 2222), and then set up an internal port forward where "X" routes port 2222 packets it receives to the RPi port 2222.

So I can't quite figure out how to do this, or if it's even the best idea... Thoughts?

  • You are doing it wrong! Rather then use SSH as a crutch, fix the routing in system X. Without knowing the OS, we can't provide specifics, but the general steps are:
    – davidgo
    Apr 28, 2018 at 21:20

1 Answer 1


There's no need to fiddle with the port number, just set up proper routing on system "X" (enable forwarding via /proc/sys/net/ipv4/ip_forward if it's Linux, etc.), and, if system "X" isn't the gateway, also set routes in the 192.168.0.xxx subnet hosts.

Then you can reach from the 192.168.0.xxx subnet.


I'll assume your subnet is a /24-er subnet (netmask; if not, modifying the following according to the netmask you used. You didn't give enough information about your networking setup, so let's say X has on eno1. Make sure this address is static and doesn't change; if your router does DHCP, use the webinterface of the router to assign X a static IP e.g. using the MAC address of eno1.

First try setting the routes manually:

On any Linux (including CentOS): ip route add via dev eth0, where eth0 is the 192.168.0.xxx network interface on the machine where you set the route.

On Windows: Open terminal, type route add mask

Then test with ping etc. if the routing works. Use tcpdump -ni eno1 etc. on system X to debug if anything goes wrong.

If everything works, make the routes static. That depends on your CentOS setup; on Windows, see e.g. here. Similar tutorials are easy to find, google. Also consider googling for networking tutorials in general, so you have some background about why what you just did works.

  • I just enabled forwarding (Centos 7) via /etc/sysctl.conf with net.ipv4.ip_forward = 1. The gateway for 192 is my router. How can tell other Centos (and Windows 10) machines on my network that is behind Apr 28, 2018 at 21:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .