PowerShell RemoteAccess module (5/5)
The last part of the RemoteAccess module: the Set- cmdlets for VPN login and protocols, RADIUS, client IP assignment, server IPsec settings, SSTP proxy, S2S interfaces, tenant routing domains and the load balancer, plus Start-/Stop-BgpPeer, Set-RoutingProtocolPreference, Uninstall-RemoteAccess and Update-DAMgmtServer. The lab stops and starts a BGP peer and changes administrative distance in FRRouting.
259.1 Why is it used?
- Decide who checks VPN logins (Windows or external RADIUS) and which protocols are allowed.
- Control where VPN clients get their IP (DHCP or a static pool).
- Pause a BGP peer for maintenance and bring it back cleanly.
- Choose which protocol's route wins for the same prefix.
- Office PC is Windows 11 without the RRAS role: Count 0; syntax/output from Microsoft Learn.
259.2 How it works
- Step 1
1.VPN client at home connects over the internet with SSTP 443 / IKEv2 to RRAS 131.107.0.10
- Step 2
2.Auth type is ExternalRadius: RRAS sends Access-Request (EAP / MSCHAPv2) to RADIUS 10.1.1.1
- Step 3
3.RADIUS returns Access-Accept
- Step 4
4.RRAS gives the client 30.1.1.10 from the StaticPool
- Step 5
5.Client traffic goes on to the app server in the corp LAN
259.3 VPN login, RADIUS and IP assignment
| Cmdlet | Key options | Note |
|---|---|---|
| Set-VpnAuthType | -Type Windows|ExternalRadius (required), -RadiusServer, -SharedSecret, -RadiusScore (30), -RadiusTimeout (5 s) | Who checks the login |
| Set-VpnAuthProtocol | -UserAuthProtocolAccepted EAP|Certificate|MsChapv2|Chap|PAP|PreSharedKey, -TunnelAuthProtocolsAdvertised, -RootCertificateNameToAccept | Applies after a service restart |
| Set-RemoteAccessRadius | -ServerName + -Purpose select; -Timeout, -Port, -Score, -SharedSecret | Changes an existing RADIUS entry |
| Set-VpnIPAddressAssignment | -IPAssignmentMethod Dhcp|StaticPool, -IPAddressRange, -IPv6Prefix | Service restart needed |
Set-VpnAuthType -Type "ExternalRadius" -RadiusServer "10.1.1.1" ` -SharedSecret "s3cr3t" -PassThruSet-VpnAuthProtocol -UserAuthProtocolAccepted Certificate -PassThruSet-RemoteAccessRadius -ServerName 10.1.2.1 -Purpose Authentication ` -Timeout 10 -SharedSecret "n3ws3cr3t" -PassThruSet-VpnIPAddressAssignment -IPAssignmentMethod "StaticPool" ` -IPAddressRange "30.1.1.10", "30.1.1.30" ` -IPv6Prefix "2002:836b:2:1000::/64" -PassThruPS C:\> Set-VpnAuthProtocol -UserAuthProtocolAccepted Certificate -PassThruWARNING: Configuration parameters will be modified after the Remote Access service is restarted.UserAuthProtocolAccepted : {Certificate}TunnelAuthProtocolsAdvertised : CertificatesRootCertificateNameToAccept :CertificateAdvertised :PS C:\>Set-VpnIPAddressAssignment -IPAssignmentMethod "StaticPool" -IPAddressRange "30.1.1.10", "30.1.1.30" -IPv6Prefix "2002:836b:2:1000::/64" -PassThruWARNING: The remoteaccess service must be restarted for the changes to take effect.IPAssignmentMethod : StaticPoolIPAddressRangeList : {30.1.1.10 - 30.1.1.30}IPv6Prefix : 2002:836b:2:1000::/64259.4 Server configuration, SSTP proxy, S2S interface
- Set-VpnServerConfiguration -CustomPolicy: -EncryptionMethod, -DhGroup, -PfsGroup, -IntegrityCheckMethod; -IdleDisconnectSeconds; port counts (-Ikev2Ports, -SstpPorts ...); -RevertToDefault.
- Set-VpnSstpProxyRule: maps a tenant ID to its -GatewayAddress.
- Set-VpnS2SInterface (-Name required): -Destination, -AuthenticationMethod EAP|MachineCertificates|PSKOnly|MSCHAPv2, -IPv4Subnet subnet:metric.
- Other S2S groups: dial (-AutoConnectEnabled, -NumberOfTries, -Persistent), IPsec, bandwidth limits, GRE.
- Step 1
1.Branch router builds an IKEv2 tunnel to RRAS through interface Edge1
- Step 2
2.RRAS shows Edge1: Connected
- Step 3
3.Traffic from 172.23.90.0/24 enters the tunnel
- Step 4
4.RRAS routes it to the app server in the corp LAN
- Step 5
5.Set-VpnS2SInterface changes exactly this interface's settings
Set-VpnServerConfiguration -CustomPolicy -EncryptionMethod "AES128" ` -DhGroup "Group2" -PfsGroup "PFS2" -CipherTransformConstants "AES128" ` -IntegrityCheckMethod "SHA256" -AuthenticationTransformConstants "SHA256128" -PassThruSet-VpnSstpProxyRule -TenantID "Contso" -GatewayAddress "10.10.10.100" -Confirm:$False Set-VpnS2SInterface -Name "Edge1" -Destination 131.107.0.4 -PassThruSet-VpnS2SInterface -Name "Edge1" -AuthenticationMethod EAP ` -EapMethod EAP-MSCHAPv2 -PassThruSet-VpnS2SInterface -Name "Edge1" -IPv4Subnet 172.23.90.0/24:50 -PassThruPS C:\>Set-VpnS2SInterface -Name "Edge1" -IPv4Subnet 172.23.90.0/24:50 -PassThruRoutingDomain Name Destination AdminStatus ConnectionState IPv4Subnet------------- ---- ----------- ----------- --------------- ----------Rd_001 Blue-Tunnel-2 {100.0.0.7} True Disconnected {172.23.90.0/24:50}259.5 Routing domain, load balancer, Uninstall, Update-DAMgmtServer
- Set-RemoteAccessRoutingDomain: per-tenant S2S settings: -IPAddressRange, -IPv6Prefix, IKE/IPsec algorithms, SA lifetimes, -MaximumVpnConnections, bandwidth.
- Set-RemoteAccessLoadBalancer: DIP = each server's dedicated IP, VIP = virtual IP clients connect to; -ThirdPartyLoadBalancer Enabled uses external hardware; -Disable removes the cluster config (asks confirm).
- Uninstall-RemoteAccess: removes DA + VPN; -VpnType Vpn|VpnS2S removes only one; -EntrypointName for one site.
- Update-DAMgmtServer: refreshes management servers from the domain; shows Added, Removed, Unchanged.
Set-RemoteAccessRoutingDomain -RoutingDomain Rd_01 ` -IPAddressRange @("10.0.0.1","10.0.0.10") -IPv6Prefix 3ffe::/64 ` -EncryptionType OptionalEncryption -PassthruSet-RemoteAccessLoadBalancer -DisableUninstall-RemoteAccess -VPNType VPN$x = Update-DAMgmtServer -PassThru$x.Summary$x.Servers | Format-Table -AutoSizeRoutingDomain : Rd_01RoutingStatus : Enabled and AvailableCapacity(Kbps) : 10240IPAddressRange : {10.0.0.1 - 10.0.0.10}PS C:\>Set-RemoteAccessLoadBalancer -DisableConfirmDisabling loadbalancing will disable cluster configuration. Do you want to continue?PS C:\>$x.SummaryChangesDetectedPS C:\>$x.Servers | Format-Table -AutoSizeChange: AddedDC3.domain1.corp.company.com Added {DC} {fdfe:5c64:53e1:7777::1e00:6302}SC1.domain1.corp.company.com Added {SCCM} {fdfe:5c64:53e1:7777::1e00:845A}Change: RemovedDC4.domain1.corp.company.com Removed {DC} {fdfe:5c64:53e1:7777::1e00:6301, 3000:0:30::99:1}Change: UnchangedMGT.domain1.corp.company.com Unchanged {Manual} {fdfe:5c64:53e1:7777::1e00:6301, 3000:0:30::99:1}259.6 Start-BgpPeer, Stop-BgpPeer, Set-RoutingProtocolPreference
- Start-BgpPeer -Name starts the session (+ -RoutingDomain in multi-tenant).
- Stop-BgpPeer -Name stops it; without -Force it asks; Get-BgpPeer | Stop-BgpPeer stops all.
- Set-RoutingProtocolPreference -Name AutoStatic|Local|NetMgmt|NonDoD|RIP|Static|EBgp|IBgp -Level N: lower value = higher priority.
Start-BgpPeer -Name "Site17"Stop-BgpPeer -Name "Tenant18" -ForceGet-BgpPeer | Stop-BgpPeerSet-RoutingProtocolPreference -Name "ebgp" -Level 15 -PassThruPS C:\> Set-RoutingProtocolPreference -Name "ebgp" -Level 15 -PassThruProtocol Priority (Lower value = higher priority)local 1static 3nondod 5autostatic 7netmgmt 10ebgp 15rip 120ibgp 200259.7 Lab: Stop/Start a BGP peer and administrative distance
- Step 1
1.router1 (AS 65001, .11) advertises 10.255.1-3.0/24 to router2 (AS 65002, .12) on n259-bgp
- Step 2
2.neighbor shutdown on router1: NOTIFICATION Cease (Admin Shutdown) to router2
- Step 3
3.router1 Idle (Admin); router2 withdraws all routes: No BGP prefixes displayed
- Step 4
4.no neighbor shutdown: router1 sends OPEN on TCP 179 again
- Step 5
5.Established -> UPDATE: the 3 routes are back in router2's table (about 5 s)
# router1 (n259-bgp 192.168.159.0/24, lab only)ip addr add 10.255.1.1/24 dev loip addr add 10.255.2.1/24 dev loip addr add 10.255.3.1/24 dev lo# vtysh conf t:router bgp 65001 no bgp ebgp-requires-policy neighbor 192.168.159.12 remote-as 65002 address-family ipv4 unicast network 10.255.1.0/24 network 10.255.2.0/24 network 10.255.3.0/24 # Stop-BgpPeer idea / Start-BgpPeer ideavtysh -c 'conf t' -c 'router bgp 65001' -c 'neighbor 192.168.159.12 shutdown'vtysh -c 'conf t' -c 'router bgp 65001' -c 'no neighbor 192.168.159.12 shutdown'[router2]$ vtysh -c 'show ip bgp'BGP table version is 3, local router ID is 192.168.159.12, vrf id 0 Network Next Hop Metric LocPrf Weight Path *> 10.255.1.0/24 192.168.159.11 0 0 65001 i *> 10.255.2.0/24 192.168.159.11 0 0 65001 i *> 10.255.3.0/24 192.168.159.11 0 0 65001 iDisplayed 3 routes and 3 total paths # after neighbor shutdown[router2]$ vtysh -c 'show bgp neighbors 192.168.159.11' | grep -iE 'BGP state|Last reset|Notification|Connections established' BGP state = Active Connections established 1; dropped 1 Last reset 00:00:13, Notification received (Cease/Administrative Shutdown/Hard Reset) # after no neighbor shutdown[router2]$ ip -4 route10.255.1.0/24 nhid 4 via 192.168.159.11 dev eth1 proto bgp metric 2010.255.2.0/24 nhid 4 via 192.168.159.11 dev eth1 proto bgp metric 2010.255.3.0/24 nhid 4 via 192.168.159.11 dev eth1 proto bgp metric 20192.168.159.0/24 dev eth1 proto kernel scope link src 192.168.159.12- Set-RoutingProtocolPreference idea = administrative distance: floating static (distance 200) loses to eBGP (20); after distance bgp 250 250 250 + soft in, the static wins.
# router2, vtysh conf t:ip route 10.255.2.0/24 192.168.159.11 200router bgp 65002 address-family ipv4 unicast distance bgp 250 250 250# vtysh:clear bgp ipv4 unicast 192.168.159.11 soft invtysh -c 'show ip route' | grep 10.255ip -4 routeS>* 10.255.2.0/24 [200/0] via 192.168.159.11, eth1, weight 1, 00:00:18[router2]$ ip -4 route10.255.1.0/24 nhid 4 via 192.168.159.11 dev eth1 proto bgp metric 2010.255.2.0/24 nhid 4 via 192.168.159.11 dev eth1 proto static metric 2010.255.3.0/24 nhid 4 via 192.168.159.11 dev eth1 proto bgp metric 20259.8 Common mistakes
- Thinking a stopped peer keeps its routes: they leave the BGP and kernel tables within seconds; check an alternate route first.
- Changing auth protocol or IP assignment and forgetting the Remote Access service restart.
- Running Set-RemoteAccessLoadBalancer -Disable casually: it removes the whole cluster configuration.
- Comparing metrics across protocols: metric is compared only within one protocol; between protocols the preference/distance decides.
259.9 Interview tips
- Pause a peer for maintenance: Stop-BgpPeer -Name -Force, then Start-BgpPeer -Name.
- Administrative distance: same prefix from two protocols, lower value wins (FRR: static 1, eBGP 20, iBGP 200; RRAS: static 3, ebgp 15, ibgp 200).
- Floating static route = a backup static with a higher distance than the dynamic route.
- VPN with RADIUS: Set-VpnAuthType -Type ExternalRadius; pool: Set-VpnIPAddressAssignment -IPAssignmentMethod StaticPool.