Using netcat in windows to forward a tcp door to another machine

18,034

TCP tunnel (port forwarding) using Netcat

Here is how to establish a tunnel using netcat to a given host and port.

netcat -L 127.0.0.1:22 -p 8080 -vvv

Listen on port 8080 of the server, and when somebody tries to connect, establish a link with 127.0.0.1:22 (i.e.: SSH server).

netcat -L google.fr:80 -p 25000 -vvv

Listen on port 25000 of the server, and when somebody tries to connect, connect him to Google web server.

Share:
18,034

Related videos on Youtube

user59067
Author by

user59067

Updated on September 18, 2022

Comments

  • user59067
    user59067 almost 2 years

    I have a computer with windows 7 under a firewall which can only initiate connections to other computers. It has a proxy server on it (port 9000) and I want to forward it to another machine (192.168.1.1) using netcat.

    Suggestions/ideas as to how to do it? My plan was to use something like

    1) On the remote machine: nc -l -p 80 -e 'nc -l -p 9000'

    2) On the firewalled computer: nc 127.0.0.1 9000 -e 'nc 192.168.1.1 80'

    The problem is: it doesnt work. I would love to use putty's ssh2 port forwarding, but it is completely broken and the bug is there since 2003. I doubt it will ever be fixed.