Configuring the Registry for Port Allocations and Selective Binding

Starting with Windows 2000, a utility in the Windows Resource Kit called Rpccfg.exe should be used to set bindings. For more information, consult the Windows Resource Kit for the appropriate operating system version.

For versions of windows prior to Windows 2000, the registry keys in the following table specify the system defaults for dynamic port allocation and for binding to NICs on multihomed computers. You must first create these keys and then specify the appropriate settings.

Using the RpcServerUseProtseqEx function affects these settings. Developers should be familiar with the registry settings explained in this section and the RpcServerUseProtseqEx function when managing port allocations. An example with three hypothetical applications follows the table below, and illustrates how these settings and the RpcServerUseProtseqEx function interoperate.

If a key is missing or if it contains an invalid value, the entire configuration is marked as invalid, and all RpcServerUseProtseq* calls over ncacn_ip_tcp or ncadg_ip_udp will fail.

Note  Ports allocated to a process remain allocated until that process dies. If all available ports are in use, the function returns RPC_S_OUT_OF_RESOURCES.

Port keyData typeDescription
HKEY_LOCAL_MACHINE
   Software
      Microsoft
         Rpc
            Internet
               Ports
REG_MULTI_SZSpecifies a set of IP port ranges consisting of either all the ports available from the Internet or all the ports not available from the Internet. Each string represents a single port or an inclusive set of ports (for example,1000-1050, 1984). If any entries are outside the range 0 to 65535, or if any string cannot be interpreted, the RPC run time will treat the entire configuration as invalid.
HKEY_LOCAL_MACHINE
   Software
      Microsoft
         Rpc
            Internet
               PortsInternetAvailable
REG_SZY or N (not case-sensitive). If Y, the ports listed in the Ports key are all the Internet-available ports on that computer. If N, the ports listed in the Ports key are all those ports that are not Internet-available.
HKEY_LOCAL_MACHINE
   Software
      Microsoft
         Rpc
            Internet
               UseInternetPorts
REG_SZY or N (not case-sensitive). Specifies the system default policy. If Y, the processes using the default will be assigned ports from the set of Internet-available ports, as defined above. If N, processes using the default will be assigned ports from the set of intranet-only ports.
HKEY_LOCAL_MACHINE
   System
      CurrentControlSet
         Services
            Rpc
               Linkage
                  Bind
REG_MULTI_SZLists the device names of all the NICs on which to bind by default (for example, \Device\AMDPCN1). If the key does not exist, the server will bind to all NICs. If the key does exist, the server will bind to the NICs specified in the key, unless the NICFlags field is set to RPC_C_BIND_TO_ALL_NICS. If the key has a null ("") value, the configuration will be marked as invalid and all calls to RpcServerUseProtseq* over ncacn_ip_tcp or ncadg_ip_udp will fail.

 

The following table illustrates how three sample applications are affected by the settings defined in the previous table, and how settings applied using the RpcServerUseProtseqEx function are also affected.

In this example, three hypothetical applications are considered:

  • InternetApp: This application is intended for exposure to the Internet, and has specified RPC_C_USE_INTERNET_PORT in the EndpointFlags member of the RPC_POLICY structure passed to the RpcServerUseProtseqEx function.
  • LocalApp: This application is not intended for exposure to the Internet, and has specified RPC_C_USE_INTRANET_PORT in the EndpointFlags member of the RPC_POLICY structure passed to the RpcServerUseProtseqEx function.
  • DefaultApp: This application specifies zero in the EndpointFlags member of the RPC_POLICY structure passed to the RpcServerUseProtseqEx function.

The following table explains the impact these settings have based on values specified in the registry entries explained in the previous table. For formatting considerations, the following codes are assigned:

PIA = PortsInternetAvailable Key value

UIP = UseInternetPorts Key value

The value of the Ports key, for sake of this example, is 5000-5100 for each entry.

ApplicationPIAUIPResult
InternetAppYYUses ports between 5000 and 5100
LocalAppYYUses a port outside the 5000-5100 range
DefaultAppYYUses ports between 5000 and 5100
InternetAppY NUses ports between 5000 and 5100
LocalAppY NUses a port outside the 5000-5100 range
DefaultAppY NUses a port outside the 5000-5100 range
InternetAppNYUses a port outside the 5000-5100 range
LocalAppNYUses ports between 5000 and 5100
DefaultAppNYUses a port outside the 5000-5100 range
InternetApp N NUses a port outside the 5000-5100 range
LocalApp N NUses ports between 5000 and 5100
DefaultApp N NUses ports between 5000 and 5100

 

Related topics

RPC_POLICY
RpcServerUseAllProtseqsEx
RpcServerUseAllProtseqsIfEx
RpcServerUseProtseqEx
RpcServerUseProtseqEpEx
RpcServerUseProtseqIfEx
ncacn_ip_tcp
ncadg_ip_udp

 

 

Community Additions

ADD
Show:
© 2014 Microsoft