How to configure RPC to use certain ports and how to help secure those ports by using IPsec
SUMMARYThis article describes how to configure RPC to use a specific dynamic port range and how to help secure the ports in that range by using an Internet Protocol security (IPsec) policy. By default, RPC uses ports in the ephemeral port range (1024-5000) when it assigns ports to RPC applications that have to listen on a TCP endpoint. This behavior can make restricting access to these ports challenging for network administrators. This article discusses ways to reduce the number of ports available to RPC applications and how to restrict access to these ports by using a registry-based IPsec policy. Because the steps in this article involve computer-wide changes that require the computer to be restarted, all these steps should be performed first in nonproduction environments to identify any application-compatibility issues that may occur as the result of these changes. MORE INFORMATION There are multiple configuration tasks that must be completed in order to relocate, reduce, and restrict access to RPC ports. First, the RPC dynamic port range should be restricted to a smaller, more manageable port range that is easier to block by using a firewall or IPsec policy. By default, RPC dynamically allocates ports in the range of 1024 to 5000 for endpoints that do not specify a port on which to listen. Note This article uses the port range of 5001 to 5021 to avoid exhausting ephemeral ports and to reduce the number of ports available to RPC endpoints from 3,976 to 20. Next, an IPsec policy must be created to restrict access to this port range to deny access to all hosts on the network. Finally, the IPsec policy can be updated to give certain IP addresses or network subnets access to the blocked RPC ports and to exclude all others. To start the task of reconfiguring the RPC dynamic port range, download the RPC Configuration Tool (RPCCfg.exe), and then copy it to the workstation or to the server that will be reconfigured. To do this, visit the following Microsoft Web site: http://www.microsoft.com/downloads/details.aspx?FamilyID=0f9cde2f-8632-4da8-ae70-645e1ddaf369&DisplayLang=en (http://www.microsoft.com/downloads/details.aspx?FamilyID=0f9cde2f-8632-4da8-ae70-645e1ddaf369&DisplayLang=en) To perform the subsequent tasks of creating an IPsec policy, download the Internet Protocol Security Policies Tool (Ipsecpol.exe), and then copy it to the workstation or to the server that will be reconfigured. To do this, visit the following Microsoft Web site:http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=7D40460C-A069-412E-A015-A2AB904B7361 (http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=7D40460C-A069-412E-A015-A2AB904B7361) Note To create an IPsec policy for Microsoft Windows XP or for a later version of the Windows operating system, use Ipseccmd.exe. Ipseccmd.exe is part of the Windows XP support tools. The syntax and usage of IPseccmd.exe are the same as the syntax and usage of Ipsecpol.exe.
For more information about the Windows XP support tools, click the following article number to view the article in the Microsoft Knowledge Base:
838079 (http://support.microsoft.com/kb/838079/)
Windows XP Service Pack 2 Support Tools
Relocate and reduce the RPC dynamic port range by using RPCCfg.exeTo relocate and reduce the RPC dynamic port range by using RPCCfg.exe, follow these steps:
Use an IPsec or firewall policy to block access to the vulnerable ports on the affected hostAfter you follow the instructions for restricting the RPC dynamic port range, the new RPC dynamic port range that is made available is 5001 to 5021. TCP 135 should be blocked by an IPsec or firewall policy. Additionally, this port range should be screened or filtered either at the perimeter or on the host. Additionally, this port range should be filtered by using an IPsec policy.In the commands in the following section, any text that appears between percent (%) signs is intended to represent text in the command that must be entered by the person who creates the IPsec policy. For example, wherever the text "%IPSECTOOL%" appears, the person who creates the policy should substitute that text as follows:
813878 (http://support.microsoft.com/kb/813878/)
How to block specific network protocols and ports by using IPSec
Block access to the RPC Endpoint Mapper for all IP addressesTo block access to the RPC Endpoint Mapper for all IP addresses, use the following syntax.Note On Windows XP and on later operating systems, use Ipseccmd.exe. On Windows 2000, use Ipsecpol.exe (Windows 2000). Note Do not type "%IPSECTOOL%" in this command. "%IPSECTOOL%" is intended to represent the part of the command that must be customized.
For example, on Windows 2000, type the following command from a directory that contains Ipsecpol.exe to block all incoming access to TCP 135:On Windows XP and on later operating systems, type the following command from a directory that contains Ipseccmd.exe to block all incoming access to TCP 135:
Block access to the RPC dynamic port range for all IP addressesTo block access to the RPC dynamic port range for all IP addresses, use the following syntax.Note On Windows XP and on later operating systems, use Ipseccmd.exe. On Windows 2000, use Ipsecpol.exe (Windows 2000). Note Do not type "%IPSECTOOL%" or "%PORT%" in this command. "%IPSECTOOL%" and "%PORT%" are intended to represent parts of the command that must be customized.
For example, type the following command on Windows 2000 hosts to block all incoming access to TCP 5001:To block all incoming access to TCP 5001, type the following command on Windows XP hosts and on hosts of later Windows operating systems:
Repeat this command for each RPC port that must be blocked by changing the port number that is listed in this command. Ports that must be blocked are in the 5001-5021 range.Note Do not forget to change the port number in the rule name (the -r switch) and in the filter (the -f switch). Optional: Give access to the RPC Endpoint Mapper for specific subnets if access is neededIf you must give specific subnets access to the restricted RPC ports, you must first give these subnets access to the RPC Endpoint Mapper that you blocked earlier. To give a specific subnet access to the RPC Endpoint Mapper, use the following command:Note In this command, the following statements apply:
Optional: Give access to the new RPC dynamic port range for specific subnets if access is neededEach subnet that was given access to the RPC Endpoint Mapper earlier should also be given access to all the ports in the new RPC dynamic port range (5001-5021).If you enable subnets to reach the RPC Endpoint Mapper but not the dynamic port range, the application may stop responding, or you may experience other problems. The following command gives a specific subnet access to a port in the new RPC dynamic port range: Note In this command, the following statements apply:
Assign the IPsec policyNote The commands in this section take effect immediately.After you create all the block rules and all the optional allow rules for the configured RPC ports, assign the policy by using the following command: Note To immediately unassign the policy, use the following command:
Note To delete the policy from the registry, use the following command:
You must restart the host for the changes to take effect.Notes
Note The server may require more than 20 TCP ports. You can use the rpcdump.exe command to count the number of RPC endpoints that are bound to a TCP port and to increase this number if you must. For more information about how to obtain the RPC Dump tool, visit the following Microsoft Web site: http://www.microsoft.com/downloads/details.aspx?displaylang=en&familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd (http://www.microsoft.com/downloads/details.aspx?displaylang=en&familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd) APPLIES TO
| Article Translations
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Back to the top
