How to Clear the Windows Distributed Routing Table (DRT) Cache via PowerShell

The Peer-to-Peer Subsystem

Windows 10, Windows 11, and modern Windows Server editions rely on a hidden peer-to-peer networking framework called the Distributed Routing Table (DRT). The DRT is primarily used by the Windows Delivery Optimization (WDO) service, HomeGroup (in older versions), and advanced DirectAccess IPv6 transition technologies like Teredo. It allows Windows machines on the same local subnet to securely discover each other without relying on a centralized DNS server, facilitating peer-to-peer sharing of Windows Updates and Store Apps.

To function efficiently, the DRT maintains a local cache of known peer IP addresses, cryptographic keys, and routing vectors. If a massive network change occurs—such as a company migrating from a 192.168.1.x subnet to a 10.0.0.x subnet, or changing their corporate firewall’s NAT configuration—the local DRT cache becomes hopelessly stale.

When this happens, Windows Delivery Optimization will completely break. Laptops will stubbornly try to download multi-gigabyte Windows Updates from non-existent peers on the old subnet, causing the CPU to spike and the Windows Update service to freeze at 0%. Restarting the computer does not fix this, as the routing cache is permanently written to the SSD. You must forcefully obliterate the DRT cache via PowerShell.

Locating the DRT Caches

The Distributed Routing Table operates at the lowest levels of the network stack. Its state files are heavily protected by the LocalService account and are buried deep within the Windows System32 directory, specifically inside the PeerNetworking subfolder.

Purging the Cache via PowerShell

You cannot use File Explorer to delete these files. You must use an elevated PowerShell session as an Administrator to stop the underlying network services, release the NTFS file locks, and perform a recursive deletion.

Step 1: Terminating the Peer Networking Services

Before touching the cache, you must violently terminate the three primary services that compose the Windows Peer-to-Peer ecosystem: the Identity Manager, the Grouping Service, and the PNRP (Peer Name Resolution Protocol) service.

# Stop the Peer Networking Identity Manager
Stop-Service -Name p2pimsvc -Force -ErrorAction SilentlyContinue

# Stop the Peer Name Resolution Protocol
Stop-Service -Name PNRPsvc -Force -ErrorAction SilentlyContinue

# Stop the Peer Networking Grouping service
Stop-Service -Name p2psvc -Force -ErrorAction SilentlyContinue

Step 2: Obliterating the Local Routing Cache

Now that the services are dead and the file locks are released, navigate to the highly restricted PeerNetworking directory and delete everything inside it.

$DRT_Cache = "$env:windir\ServiceProfiles\LocalService\AppData\Roaming\PeerNetworking"

if (Test-Path $DRT_Cache) {
    # Recursively force delete all RSA keys, ID files, and routing databases
    Remove-Item -Path "$DRT_Cache\*" -Recurse -Force -ErrorAction SilentlyContinue
    
    Write-Host "Distributed Routing Table (DRT) cache completely purged." -ForegroundColor Green
}

Step 3: Flushing the Global DNS and Winsock Stacks

Because the DRT is tightly integrated with Windows networking, you should also flush the standard DNS cache and reset the Winsock catalog to ensure no stale Teredo or IPv6 transition tunnels are lingering in the memory.

Clear-DnsClientCache
netsh winsock reset

The Network Reinitialization

The cache is now physically gone. You must restart the computer to finalize the Winsock reset and allow the operating system to boot into a clean state.

When Windows reboots, the p2pimsvc service will start automatically. It will look for the PeerNetworking folder, realize the cache is empty, and immediately broadcast a fresh discovery packet across the local subnet. It will generate a completely new set of cryptographic keys and build a fresh routing table mapping the exact, current IP addresses of its neighbors. The Delivery Optimization engine will instantly recover, allowing Windows Updates to download seamlessly across the local LAN.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.