LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-30-2022, 08:16 AM   #1
RickPoleshuck
Member
 
Registered: Jun 2019
Posts: 30

Rep: Reputation: Disabled
SSH Forwarding, Double NAT, and LAN access


I have 3 hosts in 2 LANs. Host A and B are in one LAN and host C is in another LAN. Host C has a persistent SSH tunnel to host A which allows me to connect from host A to host C. Can someone tell me how to make that tunnel available to host B?

From host A I can access
Code:
http://localhost:3456
which is tunneled to host C and that works perfectly. But I would also like to use
Code:
http://A:3456
from host B. Host B and host A are in the same LAN, no tunneling required.

This is how I create the SSH tunnel on host C

Code:
$ /usr/bin/autossh -o "ServerAliveInterval 10" -o "ServerAliveCountMax 3" -N -R 3456:localhost:3456 A.DOMAIN.NAME
I am guessing there is some configuration on host A's /etc/ssh/sshd_config that needs to be made.

I hope I have explained my problem clearly...
 
Old 07-30-2022, 10:32 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,784

Rep: Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937Reputation: 5937
The default setting in sshd_config is GatewayPorts no which will only bind remote ports to localhost. If set to yes it will bind to any port.

Code:
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:3456          0.0.0.0:*               LISTEN
The output of the comand netstat -tunlp will show all zeros instead of 127.0.0.1. All zeros indicates the process is bound to all ports.
 
Old 07-30-2022, 01:05 PM   #3
RickPoleshuck
Member
 
Registered: Jun 2019
Posts: 30

Original Poster
Rep: Reputation: Disabled
Thumbs up

Perfect!!!
Much thanks
Quote:
Originally Posted by michaelk View Post
The default setting in sshd_config is GatewayPorts no which will only bind remote ports to localhost. If set to yes it will bind to any port.

Code:
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:3456          0.0.0.0:*               LISTEN
The output of the comand netstat -tunlp will show all zeros instead of 127.0.0.1. All zeros indicates the process is bound to all ports.
 
  


Reply

Tags
lan, ssh, tunnel



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ip forwarding with iptables - double forwarding with openVPN?? sousacanfly Linux - Networking 8 01-20-2014 08:49 AM
[SOLVED] SSH no route to host error. can ssh outside lan, but not to clients on lan... jmd9qs Linux - Networking 3 01-21-2012 10:28 AM
NAT and NAT Server behind its own NAT(private network) zeusys Linux - Networking 1 06-08-2011 06:22 PM
SSH port forwarding thru a NAT Firewall whoever Linux - Networking 3 07-29-2005 03:24 AM
Firewall/NAT issues with X-Server w/ SSH forwarding JMCraig Linux - Security 1 01-25-2005 12:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration