21

What I want is to configure a computer in home with Windows and use it as a TCP proxy for connect and route packets from the 80 to port 23 in another server in the Internet

victor hugo
  • 588
  • 3
  • 8
  • 16

5 Answers5

79

You can use the built-in netsh portproxy. In your case:

netsh interface portproxy add v4tov4 listenport=80 connectaddress=ip-of-server-on-internet connectport=23 listenaddress=ip-of-windows-machine protocol=tcp

You'll need Administrator privileges. No need to install additional software!

You are required to install IPv6 on your operating system before using this feature. On Vista and later this is a non-issue as IPv6 comes installed by default, but on XP/2003 you have to open up your network interface property panel, and add the Microsoft TCP/IP version 6 protocol first.

mtnielsen
  • 3
  • 1
Luca Gibelli
  • 2,731
  • 1
  • 22
  • 30
  • 7
    Why isn't this the accepted answer?!? – Hafthor Nov 09 '12 at 21:28
  • @Hafthor: probably just because it turned up a while after the other answers came in and one was already accepted. It is certainly something I'll try first next time I need such a server under Windows. – David Spillett Jan 03 '13 at 15:29
  • +1 for explaining this won't work on xp/2003 without adding support for IPv6 to the network interface properties. – dimir Apr 23 '13 at 15:14
  • 1
    this is a fantastic answer! – Dima Oct 15 '17 at 20:09
  • 1
    This is awesome sauce. If it's an unusual port don't forget to immediately `wf.msc` and let it through the firewall! – BaseZen Jan 05 '18 at 01:32
  • 1
    amazing! worked like a charm. This MUST become the accepted answer! – atomaras Jul 18 '18 at 22:10
  • I would upvote this a zillion times if I could. It is a life-saver - such simple and efficient. One question, though: Is this a permanent setting which survives reboots? – Binarus Jan 04 '20 at 17:52
  • This doesn't work when I connect to this "proxy" from remote machine. – anton_rh Sep 10 '20 at 08:06
  • @anton_rh care to elaborate? It is supposed to work – Luca Gibelli Sep 10 '20 at 12:44
  • `netsh interface portproxy add v4tov4 listenport=81 listenaddress=0.0.0.0 connectport=80 connectaddress=google.com protocol=tcp`. When I do `telnet xxx.xxx.xxx.xxx 81` from local machine, it works. But when I do this from remote machine in my network, it doesn't work. _xxx.xxx.xxx.xxx_ is surely reachable. Maybe some Windows Firewall issues or domain settings. But I don't care, I just use 3rd party tiny TCP proxy and it just works. – anton_rh Sep 11 '20 at 03:30
  • Mandatory ***THANKS**, this is great* :) needed to locally enable the getUserMedia HTML5 API surface which only works on HTTPS - or 127.0.0.1. Since anything can theoretically do this, this approach is no less secure. – i336_ Sep 28 '21 at 08:12
  • 2
    Command to shut down the created proxy: `netsh interface portproxy delete v4tov4 listenport=8081 listenaddress=0.0.0.0 protocol=tcp` – amasmiller Dec 22 '21 at 15:58
16

Note: Luca's answer which arrived three years after this one was accepted, is probably the one that you want if running Vista or later.


rinetd should do the job, and a Windows binary for it can be had from [sorry, link no longer valid] (for anyone looking for the same thing under Linux, rinetd is in the standard repositories of just about every distro so can be installed with "apt-get install rinetd" or "yum install rinetd" or similar)

Note: the previous link to a Windows binary is no longer valid. Windows builds of the tool can be found in cygwin and similar packages, after a cursory search I didn't find a direct link to a stand-alone Windows binary to replace the link with. All references found pointed to the same, now invalid, link.

David Spillett
  • 22,754
  • 45
  • 67
  • That link looks down to me? Or is it supposed to redirect to a loans website? – CLOVIS Oct 22 '20 at 15:00
  • Looks like the domain lapsed and has been taken over. I couldn't find a replacement location for a stand-alone Windows binary. I've updated the question accordingly. – David Spillett Oct 22 '20 at 17:13
  • @DavidSpillett https://github.com/samhocevar/rinetd has a windows binary in the releases section. – psychowood Oct 03 '22 at 20:46
2

You're looking for a TCP proxy. There are a variety of free TCP proxies for Windows. I'm not going to recommend one because I don't have any good experience with any of them. Google for "Windows TCP proxy" and you'll come up with a boatload.

This one is cute and source is available, but I don't know how reliable: http://dposey.no-ip.com/Proxy/

It's a fairly trivial piece of code, though one could put some pretty neat features into a high-end TCP proxy (load balancing, logging of traffic, etc).

Evan Anderson
  • 141,881
  • 20
  • 196
  • 331
2

Assuming it's http packets you could use one of the many windows proxies out there Like Squid NT or something similar.

But if you just wanna port forward any packets, SSH tunneling is the way to go. Check out sshwindows for the server piece and http://oldsite.precedence.co.uk/nc/putty.html for a quick howto on how to set up port forwarding in PuTTY.

There might be an easier way using Some built in Microsoft tool, but this is what came to the top of my head first.

skitzot33
  • 554
  • 2
  • 2
1

3proxy is a small and flexible cross-platform multipurpose proxy which can act as a TCP proxy too.

Gleb
  • 538
  • 3
  • 7