Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.networking > #4820

Re: Forwarding a TCP connection

From "Carlos E.R." <robin_listas@es.invalid>
Newsgroups comp.os.linux.networking
Subject Re: Forwarding a TCP connection
Date 2021-03-14 23:26 +0100
Message-ID <a5f2ih-eu3.ln1@Telcontar.valinor> (permalink)
References <s2lqd7$1ljv$1@gioia.aioe.org> <phc2ih-jjv.ln1@Telcontar.valinor> <87czw1v1g0.fsf@LkoBDZeT.terraraq.uk>

Show all headers | View raw


On 14/03/2021 23.02, Richard Kettlewell wrote:
> "Carlos E.R." <robin_listas@es.invalid> writes:
>> On 14/03/2021 21.07, John Smith wrote:
>>> 	I have a Linux system A in my network where a TCP server is
>>> running at port P. The details of this server are irrelevant beyond the
>>> fact that it is a TCP server.
>>>
>>> 	What I would like to do is the following;
>>>
>>> 	I have another Linux system B in the same network. Would it be
>>> possible to configure B so that when be receives a TCP connection request
>>> on port B, the connection is silently and transparently forwarded to A?
>>> That is, my goal is for B to act as man-in-the-middle, totally
>>> transparent as far as B is concerned.
>>>
>>> 	Can this be done?
> 
> I used to use the iptables DNAT and SNAT targets to achieve this.
> 
>> Certainly.
>>
>> For example, with an ssh tunnel, run on B:
>>
>> ssh -L 127.0.0.01:60000:192.168.1.16:80 -N user@A.mylan
>>
>>
>> A is on 192.168.1.16 in the example.
> 
> With this approach, the server on A will see the wrong source address,
> not very transparent.

You can change the options as needed. I basically pasted what I use.


      -L [bind_address:]port:host:hostport
      -L [bind_address:]port:remote_socket
      -L local_socket:host:hostport
      -L local_socket:remote_socket
              Specifies that connections to the given TCP port
              or Unix socket on the local (client) host are to
              be forwarded to the given host and port, or Unix
              socket, on the remote side.  This works by allo-
              cating a socket to listen to either a TCP port
              on the local side, optionally bound to the spec-
              ified bind_address, or to a Unix socket.  When-
              ever a connection is made to the local port or
              socket, the connection is forwarded over the
              secure channel, and a connection is made to
              either host port hostport, or the Unix socket
              remote_socket, from the remote machine.

              Port forwardings can also be specified in the
              configuration file.  Only the superuser can for-
              ward privileged ports.  IPv6 addresses can be
              specified by enclosing the address in square
              brackets.

              By default, the local port is bound in accor-
              dance with the GatewayPorts setting.  However,
              an explicit bind_address may be used to bind the
              connection to a specific address.  The
              bind_address of “localhost” indicates that the
              listening port be bound for local use only,
              while an empty address or ‘*’ indicates that the
              port should be available from all interfaces.



-- 
Cheers, Carlos.

Back to comp.os.linux.networking | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Forwarding a TCP connection John Smith <12345@whatismyemailaddress.xyz> - 2021-03-14 20:07 +0000
  Re: Forwarding a TCP connection "Carlos E.R." <robin_listas@es.invalid> - 2021-03-14 22:41 +0100
    Re: Forwarding a TCP connection Richard Kettlewell <invalid@invalid.invalid> - 2021-03-14 22:02 +0000
      Re: Forwarding a TCP connection "Carlos E.R." <robin_listas@es.invalid> - 2021-03-14 23:26 +0100
        Re: Forwarding a TCP connection Richard Kettlewell <invalid@invalid.invalid> - 2021-03-14 22:46 +0000
      Re: Forwarding a TCP connection Pascal Hambourg <pascal@plouf.fr.eu.org> - 2021-03-15 09:42 +0100
  Re: Forwarding a TCP connection Jim Jackson <jj@franjam.org.uk> - 2021-03-14 22:03 +0000
  Re: Forwarding a TCP connection "David W. Hodgins" <dwhodgins@nomail.afraid.org> - 2021-03-14 17:40 -0400
    Re: Forwarding a TCP connection John Smith <12345@whatismyemailaddress.xyz> - 2021-03-14 23:23 +0000
    Re: Forwarding a TCP connection dyrmak <dyrmak@quelite.terre.invalid> - 2021-03-15 17:49 +0000
      Re: Forwarding a TCP connection Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2021-03-15 20:14 +0200
      Re: Forwarding a TCP connection "Carlos E.R." <robin_listas@es.invalid> - 2021-03-15 23:28 +0100
        Re: Forwarding a TCP connection Jorgen Grahn <grahn+nntp@snipabacken.se> - 2021-03-15 23:15 +0000
          Re: Forwarding a TCP connection dyrmak <dyrmak@orange.fr.invalid> - 2021-03-16 07:59 +0000
          Re: Forwarding a TCP connection Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2021-03-16 11:16 +0200
            Re: Forwarding a TCP connection Jim Jackson <jj@franjam.org.uk> - 2021-03-16 14:53 +0000
          Re: Forwarding a TCP connection "Carlos E.R." <robin_listas@es.invalid> - 2021-03-16 03:21 +0100
          Re: Forwarding a TCP connection Jim Jackson <jj@franjam.org.uk> - 2021-03-16 14:49 +0000
            Re: Forwarding a TCP connection Johann Beretta <beretta@nun-ya-bizness.com> - 2021-05-28 13:19 -0700
              Re: Forwarding a TCP connection Grant Taylor <gtaylor@tnetconsulting.net> - 2021-05-28 16:20 -0600
        Re: Forwarding a TCP connection Johann Beretta <beretta@nun-ya-bizness.com> - 2021-05-28 13:15 -0700
          Re: Forwarding a TCP connection Grant Taylor <gtaylor@tnetconsulting.net> - 2021-05-28 16:23 -0600
            Re: Forwarding a TCP connection Marc Haber <mh+usenetspam1118@zugschl.us> - 2021-05-29 18:42 +0200
              Re: Forwarding a TCP connection Grant Taylor <gtaylor@tnetconsulting.net> - 2021-05-29 19:29 -0600
                Re: Forwarding a TCP connection Marc Haber <mh+usenetspam1118@zugschl.us> - 2021-05-30 12:08 +0200
                Re: Forwarding a TCP connection Grant Taylor <gtaylor@tnetconsulting.net> - 2021-05-31 22:43 -0600
                Re: Forwarding a TCP connection Marc Haber <mh+usenetspam1118@zugschl.us> - 2021-06-01 08:51 +0200
    Re: Forwarding a TCP connection Johann Beretta <beretta@nun-ya-bizness.com> - 2021-03-24 19:30 -0700
      Re: Forwarding a TCP connection Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2021-03-25 16:35 +0200
        Re: Forwarding a TCP connection Pascal Hambourg <pascal@plouf.fr.eu.org> - 2021-03-25 20:03 +0100
          Re: Forwarding a TCP connection Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2021-03-25 21:34 +0200
            Re: Forwarding a TCP connection Pascal Hambourg <pascal@plouf.fr.eu.org> - 2021-03-25 21:54 +0100
            Re: Forwarding a TCP connection Johann Beretta <beretta@nun-ya-bizness.com> - 2021-03-29 13:45 -0700
        Re: Forwarding a TCP connection Johann Beretta <beretta@nun-ya-bizness.com> - 2021-03-29 13:43 -0700
          Re: Forwarding a TCP connection Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2021-03-30 20:26 +0300
            Re: Forwarding a TCP connection Johann Beretta <beretta@nun-ya-bizness.com> - 2021-03-30 22:49 -0700
              Re: Forwarding a TCP connection Charlie Gibbs <cgibbs@kltpzyxm.invalid> - 2021-03-31 16:29 +0000
  Re: Forwarding a TCP connection John Smith <12345@whatismyemailaddress.xyz> - 2021-03-14 23:13 +0000
    Re: Forwarding a TCP connection Jorgen Grahn <grahn+nntp@snipabacken.se> - 2021-03-15 06:59 +0000
    Re: Forwarding a TCP connection Pascal Hambourg <pascal@plouf.fr.eu.org> - 2021-03-15 09:48 +0100
      Re: Forwarding a TCP connection John Smith <12345@whatismyemailaddress.xyz> - 2021-03-15 13:44 +0000
        Re: Forwarding a TCP connection Pascal Hambourg <pascal@plouf.fr.eu.org> - 2021-03-15 20:49 +0100
          Re: Forwarding a TCP connection John Smith <12345@whatismyemailaddress.xyz> - 2021-03-15 21:10 +0000

csiph-web