Reserving ports in the Windows 10 Dynamic Port Range

10,976

Windows Vista and higher do not support the ReservedPorts registry value. (Source)

Instead, you can use the netsh utility to achieve the same effect:

netsh int <ipv4|ipv6> Add excludedportrange [protocol=]tcp|udp [startport=]<integer> [numberofports=]<integer> [[store=]active|persistent]

You can also remove entries:

netsh int <ipv4|ipv6> delete excludedportrange [protocol=]tcp|udp [startport=]<integer> [numberofports=]<integer> [[store=]active|persistent]

...or list them:

netsh int <ipv4|ipv6> show excludedportrange [protocol=]tcp|udp [[store=]active|persistent]

I doubt any of that would affect the output of netsh int <ipv4|ipv6> show dynamicport tcp.

Share:
10,976

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I want to set a Windows 10 dynamic port range between 20000 and 29999 (inclusively), so a range of 10000 ports.

    To do this, I run the following commands:

    netsh int ipv4 set dynamicport tcp start=20000 num=10000
    netsh int ipv4 set dynamicport udp start=20000 num=10000
    netsh int ipv6 set dynamicport tcp start=20000 num=10000
    netsh int ipv6 set dynamicport udp start=20000 num=10000
    

    Following this, querying the range using the following example command:

    netsh int ipv4 show dynamicport tcp
    

    ...produces the following result:

    Protocol tcp Dynamic Port Range
    -------------------------------
    Start Port      : 20000
    Number of Ports : 10000
    

    Which looks correct to me.

    Now suppose I want to reserve certain ports within that Windows Dynamic Port Range, say 21000-21050, then I run the following command:

    reg add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\ /v ReservedPorts /t REG_MULTI_SZ /d 21000-21050 /f
    

    Following this, requerying the Windows Dynamic Port range produces the following result:

    Protocol tcp Dynamic Port Range
    -------------------------------
    Start Port      : 20000
    Number of Ports : 10000
    

    Is this expected behaviour? Or should the resultant table be fragmented somewhat to reflect the port reservations which fall within the middle of the dynamic range, e.g. something like:

    Protocol tcp Dynamic Port Range
    -------------------------------
    Start Port      : 20000, 21051 
    Number of Ports : 1000 , 8950
    

    My port reservation command has updated the registry with the ReservedPorts setting so I assume this is all correct behaviour.

    Are there any other ways to test this process prior to deployment in a system?

    Thanks

  • Admin
    Admin over 5 years
    Thanks. Are you sure that ReservedPorts thing doesn't just affect Server 2008? I know the page says "This issue occurs because Windows Server 2008 and Windows Server 2008 R2 do not support the ReservedPorts registry key". Where does it say it also affects Windows 10? Thanks.
  • Daniel B
    Daniel B over 5 years
    It’s because of the new network stack since Vista/Server 2008. But really, just try. The commands I quoted are available, they will most likely work.
  • FreakyDan
    FreakyDan over 4 years
    When running the delete commands, I keep getting "Access is denied." even when running as admin. Any idea how to get around that? Haven't been able to find information regarding it.