Run BGP on Windows Server 2019

Windows Server 2019 can speak BGP without third-party software. How to install the routing role, configure the router and a peer, announce prefixes and apply policies.

Contents

Windows Server 2019 can run BGP without any third-party software, which makes routing to the host possible. The feature is not well documented, so here are the steps. I assume you already know how BGP works. The parameters of every command below are described in the RemoteAccess module documentation.

Install the routing role

Install-WindowsFeature RemoteAccess
Install-WindowsFeature RSAT-RemoteAccess-PowerShell
Install-WindowsFeature Routing
Install-RemoteAccess -VpnType RoutingOnly

Set the ASN and router ID

Add-BgpRouter -BgpIdentifier 10.10.13.111 -LocalASN 100

Add a peer

Add-BgpPeer -LocalIPAddress 10.10.13.111 -PeerIPAddress 10.10.13.171 -PeerASN 200 -Name CSR01

Announce prefixes

Add-BgpCustomRoute -Network 172.16.0.0/24
Add-BgpCustomRoute -Network 172.16.1.0/24
Add-BgpCustomRoute -Network 172.16.2.0/24
Add-BgpCustomRoute -Network 172.16.3.0/24
Add-BgpCustomRoute -Network 172.16.4.0/24

Going further

Summarise prefixes

Add-BgpRouteAggregate -Prefix 172.16.0.0/22 -SummaryOnly Enabled

Apply a policy to a peer

This adds a community and raises the local preference for 192.168.1.0/24 when it is received from CSR01, then shows the result:

Add-BgpRoutingPolicy -Name RoutePolicy -MatchPrefix 192.168.1.0/24 -PolicyType ModifyAttribute -AddCommunity 100:1001 -NewLocalPref 500
Add-BgpRoutingPolicyForPeer -PeerName CSR01 -PolicyName RoutePolicy -Direction Ingress
Get-BgpRouteInformation -Network 192.168.1.0/24 | fl

Use the host’s own address as router ID

Test-Connection returns an object, so take its address as a string before passing it on:

$ipV4 = (Test-Connection -ComputerName (hostname) -Count 1).IPV4Address.IPAddressToString
Add-BgpRouter -BgpIdentifier $ipV4 -LocalASN 65534
Add-BgpPeer -LocalIPAddress $ipV4 -PeerIPAddress 10.10.10.10 -PeerASN 64512 -Name Switch
Add-BgpCustomRoute -Network 10.21.123.10/32

Join the discussion

Comments are hosted on comments.vciso.ch, a server I run myself. Nothing is loaded from it until you press the button below. Loading comments connects your browser to that server, and signing in with GitHub sets a cookie there. See the privacy page for details.

Type to search.

↑ ↓ to move, Enter to open, Esc to close