How can I call CreatePersistentUdpPortReservation before any services/applications run? RRS feed

  • Question

  • I have a service running on Windows Server 2008 R2 which needs to reserve 14,000 UDP ports starting at a fixed address. CreatePersistentUdpPortReservation fails because one or more ports in the range have already been opened by other services e.g. DFS.

    How can I call this method before other services etc. start. Or are there registry keys which can be set to achieve the same goal. It is not a problem if a reboot is required to enact the reservation.


    Wednesday, April 10, 2013 3:37 PM

All replies

  • If you reserve ports that other services wish to use, then those services will likely fail as they are using well-known ports and expect them to be available. When reserving, you should be using ports from the ephemeral port range (49152-65535).

    Ideally you would call CreatePersistentUdpPortReservation as early in the boot process as you could (make your service boot load and have it load immediately after TCPIP).

    It is not supported to modify the registry directly to create the reservations.

    Hope this helps,

    Dusty Harper [MSFT]
    Microsoft Corporation
    This posting is provided "AS IS", with NO warranties and confers NO rights

    Wednesday, April 10, 2013 7:59 PM
  • Dusty,

    I tried to set the service to SERVICE_BOOT_START but that requires SERVICE_KERNEL_DRIVER which I added. Now when I try to install the service it fails with INVALID_PARAMETER. Based on another article I changed SERVICE_BOOT_START back to SERVICE_AUTO_START, installed the service then tried to use SC.exe to change the start type to boot but this still failed with INVALID_PARAMETER.

    So, how do I get the service to boot load? 

    I do have a device driver that I could modify to reserve the ports but  Iphlpapi doesn't appear to be available to drivers. Is there a MIB I can call from the driver that performs the same function?

    (Yes, the service will be reserving the ports from the ephemeral port range)

    Thanks, Alan

    Monday, April 15, 2013 5:06 PM