Link to home
Start Free TrialLog in
Avatar of TRS TRS
TRS TRSFlag for Greece

asked on

Port forward using netsh.exe is not working

Hi guys,
I want to enable port forward on a windows 7 machine using netsh.exe.

IPv6 is enabled.
Firewall is disabled.
I want to redirect traffic from the port 2372 (all interfaces) to 127.0.0.1:2372 .
Actually I want to access to a web service running on 127.0.0.1:2372 from another host on the same LAN.

So I am running as admin cmd and then I am using the following command:
netsh interface portproxy add v4tov4 listenport=2372 connectport=2372 connectaddress=127.0.0.1 protocol=tcp

netsh interface portproxy>show v4tov4

Listen on ipv4:             Connect to ipv4:

Address         Port        Address         Port
--------------- ----------  --------------- ----------
*               2372        127.0.0.1       2372

netsh interface portproxy>show helper
Helper GUID                             DLL Filename  Command
--------------------------------------  ------------  -------
{02BC1F81-D927-4EC5-8CBC-8DD65E3E38E8}  AUTHFWCFG.DLL  advfirewall
{FB10CBCA-5430-46CE-B732-079B4E23BE24}  AUTHFWCFG.DLL    consec
{35342B49-83B4-4FCC-A90D-278533D5BEA2}  AUTHFWCFG.DLL    firewall
{4BD827F7-1E83-462D-B893-F33A80C5DE1D}  AUTHFWCFG.DLL    mainmode
{4D0FEFCB-8C3E-4CDE-B39B-325933727297}  AUTHFWCFG.DLL    monitor
{A31CB05A-1213-4F4E-B420-0EE908B896CB}  PEERDISTSH.DLL  branchcache
{555EA58E-72B1-4F0A-9055-779D0F5400B2}  PEERDISTSH.DLL    smb
{00770721-44EA-11D5-93BA-00B0D022DD1F}  HNETMON.DLL   bridge
{6DC31EC5-3583-4901-9E28-37C28113656A}  DHCPCMONITOR.DLL  dhcpclient
{8A6D23B3-0AF2-4101-BC6E-8114B325FE17}  NETIOHLP.DLL  dnsclient
{8B3A0D7F-1F30-4402-B753-C4B2C7607C97}  FWCFG.DLL     firewall
{44F3288B-DBFF-4B31-A86E-633F50D706B3}  NSHHTTP.DLL   http
{0705ECA1-7AAC-11D2-89DC-006008B0E5B9}  IFMON.DLL     interface
{1C151866-F35B-4780-8CD2-E1924E9F03E1}  NETIOHLP.DLL    6to4
{97C192DB-A774-43E6-BE78-1FABD795EEAB}  NETIOHLP.DLL    httpstunnel
{725588AC-7A11-4220-A121-C92C915E8B73}  NETIOHLP.DLL    ipv4
{500F32FD-7064-476B-8FD6-2171EA46428F}  NETIOHLP.DLL    ipv6
{90E1CBE1-01D9-4174-BB4D-EB97F3F6150D}  NETIOHLP.DLL      6to4
{90E1CBE1-01D9-4174-BB4D-EB97F3F6150D}  NETIOHLP.DLL      isatap
{1C151866-F35B-4780-8CD2-E1924E9F03E1}  NETIOHLP.DLL    isatap
{1C151866-F35B-4780-8CD2-E1924E9F03E1}  NETIOHLP.DLL    portproxy
{78197B47-2BEF-49CA-ACEB-D8816371BAA8}  NETIOHLP.DLL    tcp
{1C151866-F35B-4780-8CD2-E1924E9F03E1}  NETIOHLP.DLL    teredo
{F7E0BC27-BA6E-4145-A123-012F1922F3F1}  NSHIPSEC.DLL  ipsec
{F7E0BC29-BA6E-4145-A123-012F1922F3F1}  NSHIPSEC.DLL    dynamic
{F7E0BC28-BA6E-4145-A123-012F1922F3F1}  NSHIPSEC.DLL    static
{1D8240C7-48B9-47CC-9E40-4F7A0A390E71}  DOT3CFG.DLL   lan
{B572D5F3-E15B-4501-84F2-6626F762AFB1}  WWANCFG.DLL   mbn
{B341E8BA-13AA-4E08-8CF1-A6F2D8B0C229}  NETIOHLP.DLL  namespace
{00B399EA-447F-4B19-8393-F9D71D7760F9}  NAPMONTR.DLL  nap
{3F8A1180-FF5D-4B5B-934C-D08DFFBC9CBC}  NAPMONTR.DLL    client
{B123BAAA-79E9-49FD-AB2C-E87C56CE4CFF}  NAPMONTR.DLL    hra
{931852E2-597D-40B9-B927-55FFC81A6104}  NETIOHLP.DLL  netio
{B7BE4347-E851-4EEC-BC65-B0C0E87B86E3}  P2PNETSH.DLL  p2p
{9E0D63D7-4644-476B-9DAC-D62F96E08376}  P2PNETSH.DLL    collab
{6ED05238-F6A3-F801-967A-5CAD6F6CAC56}  P2PNETSH.DLL      contact
{E35A9D1F-61E8-4CF5-A46C-0F715A9303B8}  P2PNETSH.DLL    group
{9AA625FC-7E31-4679-B5B5-DFC67A3510AB}  P2PNETSH.DLL      database
{FBFC037E-D455-4B8D-80A5-B379002DBCAD}  P2PNETSH.DLL    idmgr
{9E0D63D6-4644-476B-9DAC-D64F96E01376}  P2PNETSH.DLL    pnrp
{1DD4935A-E587-4D16-AE27-14E40385AB12}  P2PNETSH.DLL      cloud
{AD1D76C9-434B-48E0-9D2C-31FA93D9635A}  P2PNETSH.DLL      diagnostics
{6EC05238-F6A3-4801-967A-5C9D6F6CAC50}  P2PNETSH.DLL      peer
{0705ECA2-7AAC-11D2-89DC-006008B0E5B9}  RASMONTR.DLL  ras
{42E3CC21-098C-11D3-8C4D-00104BCA495B}  RASMONTR.DLL    aaaa
{90FE6CFC-B6A2-463B-AA12-25E615EC3C66}  RASMONTR.DLL    diagnostics
{13D12A78-D0FB-11D2-9B76-00104BCA495B}  RASMONTR.DLL    ip
{36B3EF76-94C1-460F-BD6F-DF0178D90EAC}  RASMONTR.DLL    ipv6
{592852F7-5F6F-470B-9097-C5D33B612975}  RPCNSH.DLL    rpc
{C07E293F-9531-4426-8E5C-D7EBBA50F693}  RPCNSH.DLL      filter
{D3E9D893-852F-4E22-B05D-99293065773D}  NETTRACE.DLL  trace
{C100BECD-D33A-4A4B-BF23-BBEF4663D017}  WCNNETSH.DLL  wcn
{3BB6DA1D-AC0C-4972-AC05-B22F49DEA9B6}  NSHWFP.DLL    wfp
{0BFDC146-56A3-4311-A7D5-7D9953F8326E}  WHHELPER.DLL  winhttp
{B2C0EEF4-CCE5-4F55-934E-ABF60F3DCF56}  WSHELPER.DLL  winsock
{D424E730-1DB7-4287-8C9B-0774F5AD0576}  WLANCFG.DLL   wlan


After these steps I cannot access the web service from another computer on the same LAN.
Port forward doesn't work. Any ideas???
Avatar of ded9
ded9
Flag of India image

Run this commad

netsh interface portproxy>add v4tov4 listenport=2372 connectaddress=127.0.0.1 connectport=2372 protocol=tcp





Ded9
you can't use 127.0.0.1 address, it's loopback,

use 192.168.0.1 or similar address

and your LAN must be on same subnet
or you can use listen address

example
netsh interface portproxy add v4tov4 listenaddress=10.255.255.1 listenport=445 connectaddress=10.255.255.1 connectport=44445
Avatar of TRS TRS

ASKER

@ded9

I had already tried your command without any result.

@M3rc74

Yeah, I was afraid that I couldn't use 127.0.0.1 even if I wanted to use it exactly that IP.

What if :
netsh interface portproxy add v4tov4 listenaddress=172.16.XX.XXX listenport=445 connectaddress=127.0.0.1 connectport=445

It doesn't work too. Is this a loopback again?

So what should I do,in order to access that web service from another host? It is running on 127.0.0.1 interface and I cannot change its configuration.

Installing third party software is the only option?

try
netsh interface portproxy add v4tov4 listenaddress=172.16.XX.XXX listenport=445 connectaddress=127.0.0.1 connectport=445

and then
netsh interface portproxy>show v4tov4

i'm thinking

you can add on that interface secundary IP address: 127.0.0.1

Avatar of David Johnson, CD
netsh interface portproxy add v4tov4 listenport=12345 listenaddress=192.168.1.1 connectport=443 connectaddress=192.168.1.1

is the service in fact listening on the port 2372 if it is then you shouldn't need the portproxy as it is a non standard port and the listen and connect ports are the same. In my example I remapped https to another port for a service that handles these requests.

The client must access the web service via 192.168.1.1 (in my example)

It sounds like you need to map from localhost on the client machine to the machine that the service is running on.

on the client machine

netsh interface portproxy add v4tov4  listenport=12345 listenaddress=127.0.0.1 connectport=12345 connectaddress=192.168.1.1
Avatar of TRS TRS

ASKER

@M3rc74

127.0.0.1 cannot be accepted as a secondary IP on my interface.

netsh interface portproxy>show v4tov4

Listen on ipv4:             Connect to ipv4:

Address         Port        Address         Port
--------------- ----------  --------------- ------
192.168.1.1   2372        127.0.0.1       2372


@ve3ofa

netsh interface portproxy add v4tov4  listenport=2372 listenaddress=127.0.0.1 connectport=2372 connectaddress=192.168.1.1

netsh interface portproxy>show v4tov4

Listen on ipv4:             Connect to ipv4:

Address         Port        Address         Port
--------------- ----------  --------------- ----------
127.0.0.1       2372        192.168.1.1   2372

It doesn't work. It doesn't accept connection on 192.168.1.1 interface.
Actually there is no need to use a different port. I want to use the same (the original) which is 2372.


I have tried both versions and none worked.
My web service is running by default on 127.0.0.1:2372 .
My network interface has the IP 192.168.1.1 .

I just want be able to access the web service using 192.168.1.1:2372 .
Avatar of TRS TRS

ASKER

Do you know any software that could run as a service and help me on that?
Nothing going through the loopback adapter goes out to the Internet, or leaves your system. The loopback adapter is completely contained within your system.

You must have some options to change this, is there an *.ini file or something to edit listening address?
if the service is running on your computer then from elsewhere you would need to use the netsh port forward on the other computers to access the service.
ASKER CERTIFIED SOLUTION
Avatar of TRS TRS
TRS TRS
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TRS TRS

ASKER

The only stable and working solution.