1

I'm doing some testing with a TCP client on Windows 10 (10.0-19045) but due to firewall restrictions I need to run my experiments from a local port < 1024 (not negotiable).

I thought that this was no problem... but bind() fails with "address in use" (yes, I checked netstat, no one is there) for any port < 1023. Then I checked netsh int ipv4 show excludedportrange protocol=tcp and the same for IPv6, noone is using those ports.

This feels like the "restricted port range" (1-1023) on UNIX/Linux, where only "root" can do a bind() with a local port < 1023, but this is Windows, and even as "Administrator" this still fails.

https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/default-dynamic-port-range-tcpip-chang talks about a "... well-known ports that are used by services and applications...", but I do not know where to set that (for a Cygwin process).

Does anyone know what is going on? Is there a way around this?

6
  • any reason for using a port lower than 1024? Commented Nov 11, 2023 at 13:38
  • @ElvisAdomnica "not negotiable" seems to communicate in no unclear terms that there is. One need not know the reason to understand the problem statement. Commented Nov 11, 2023 at 13:40
  • @IInspectable the reason for using a port lower that 1024 could actually give more context to the question. For instance, the question states that it needs to use that port due to firewall restrictions, so one can maybe come up with some workaround. Commented Nov 11, 2023 at 13:50
  • also, to debug this I would try a few things: bind to a higher port to make sure that I don't have some errors in my code, I would try to disable Firewall to see if things work, etc. Commented Nov 11, 2023 at 13:56
  • also, I would disable Hyper-V Commented Nov 11, 2023 at 13:58

1 Answer 1

0

https://www.betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/174904

"The Well Known Ports [those from 0 through 1023] are assigned by the IANA and on most systems can only be used by system (or root) processes or by programs executed by privileged users"

One way to run as System is to use PSexec. That's an old KB, I'm don't remember if SYSTEM still has network privileges -- you may have to find or define another user.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.