How to Clear the BGP Routing Table in Windows Server using PowerShell

The Role of BGP in Windows Server

Border Gateway Protocol (BGP) is the core routing protocol of the internet. Historically, BGP was exclusively handled by dedicated hardware routers from vendors like Cisco or Juniper. However, in modern Software-Defined Networking (SDN) environments—especially within Microsoft Azure hybrid clouds or complex Hyper-V virtualization clusters—Windows Server itself can be configured to act as a BGP router using the Remote Access service role.

When a Windows Server BGP router forms a peering session with another router, it dynamically learns hundreds or thousands of IP routes. If a network administrator makes a massive configuration change (like altering prefix filters or AS numbers), the server may retain stale routes in its routing table, leading to routing loops or dropped traffic. To resolve this, you must flush the routing table, forcing the Windows Server to re-sync with its BGP peers.

Using the Clear-BgpRoutingTable Cmdlet

PowerShell provides a dedicated module (RemoteAccess) for managing BGP routing. To execute these commands, you must run PowerShell as an Administrator on the Windows Server hosting the BGP role.

To forcefully purge the entire BGP routing table, run the following command:

Clear-BgpRoutingTable -Force

The -Force parameter bypasses the confirmation prompt. The server will immediately flush all dynamically learned routes from its memory. Within seconds, it will send a Route Refresh request to its active BGP peers to rebuild the table using the most current network topology data.

Clearing Routes from a Specific Peer

In a large datacenter, your Windows Server might peer with five different upstream routers. Flushing the entire table is a massive disruption, potentially causing brief network outages across the entire cluster while the table rebuilds.

If you know that only one specific peer (e.g., the router at 10.0.0.1) is advertising stale routes, you can target that specific neighbor.

Clear-BgpRoutingTable -PeerName "10.0.0.1"

This precision strike deletes only the routes learned from that specific IP address, leaving the rest of the routing table perfectly intact, minimizing disruption to active user sessions.

Verifying the Table Rebuild

Immediately after executing a clear command, you must verify that the server successfully pulled down fresh routes from its peers. A failure to repopulate the table indicates a severe misconfiguration in your BGP peering policies or a firewall block.

To view the current state of the newly rebuilt BGP routing table, use the Get-BgpRouteInformation cmdlet:

Get-BgpRouteInformation

This command will output a massive table detailing every network prefix, the Next Hop IP address, the Local Preference, and the exact AS Path it took to reach your Windows Server. If this table is empty after a flush, your BGP peering session is broken and requires immediate investigation.

Get the best tech tips delivered straight to your inbox.

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