0

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 10.0.0.1 subnet and connected to a RPi
    • X's IP = 10.0.0.99
    • RPi's IP = 10.0.0.100

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?

1
  • 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 '18 at 21:20
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 10.0.0.100 from the 192.168.0.xxx subnet.

Edit

I'll assume your 10.0.0.0 subnet is a /24-er subnet (netmask 255.255.255.0; 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 192.168.0.123/24 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 10.0.0.0/24 via 192.168.0.123 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 10.0.0.0 mask 255.255.255.0 192.168.0.123.

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.

1
  • 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 10.0.0.100 is behind 192.168.0.55? Apr 28 '18 at 21:42

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.