SkillPilotAI

PowerShell RemoteAccess module (4/5)

Part 4 of the RemoteAccess module: the Set- cmdlets that change live settings of BGP (peer, router, aggregate, dampening, policy), DirectAccess (client, entry points, NLS, OTP, server) and Remote Access (interfaces, accounting, IP filter). Set- changes can restart sessions, so knowing their impact matters as much as the syntax.

258.1 Why is it used?

  • Tune BGP without rebuilding it: timers, ASN, router ID, summaries, MED/local-pref.
  • Fix DirectAccess behaviour: force tunnel, NLS URL, entry point DCs, OTP.
  • Decide where connection records go (inbox store or external RADIUS) and how long they stay.
  • Office PC: Count 0; Set- changes live settings, so office VPN/DA/RADIUS were never touched.

258.2 Set-BgpPeer and Set-BgpRouter

  • Set-BgpPeer updates an existing peer: -PeeringMode, -PeerIPAddress, -LocalIPAddress, -PeerASN, -LocalASN, -OperationMode.
  • -HoldTimeSec / -IdleHoldTimeSec = session timers; -MaxAllowedPrefix / -ClearPrefixLimit; -Weight.
  • Set-BgpRouter changes -LocalASN and -BgpIdentifier (router ID), plus route reflector and IPv6 options.
  • The confirm prompt warns: active peering sessions will restart.
PowerShell
Set-BgpPeer -Name "TenantSite1" -PeeringMode Automatic -PassThruSet-BgpRouter -LocalASN 64513 -PassThru
Output
PS C:\>Set-BgpRouter -LocalASN 64513 -PassThruConfirmOne or more BGP peering sessions are active. Applying changes will restart these sessions. Do you want to continue?[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): yRoutingDomain         :BgpIdentifier         : 192.168.1.10LocalASN              : 64513CompareMEDAcrossASN   : FalseDefaultGatewayRouting : FalseIPv6Routing           : Disabled

258.3 Aggregate, dampening and routing policy

CmdletKey optionsEffect
Set-BgpRouteAggregate-SummaryOnly Enabled|Disabled, -PreserveASPath, -AttributePolicyPeers get only the summary; specific routes hidden
Set-BgpRouteFlapDampening-HalfLife, -HalfLifeUnreachable, -SuppressThreshold, -ReuseThreshold, -MaxSuppressTimePenalty above suppress = suppressed; below reuse = used again
Set-BgpRoutingPolicy-PolicyType Deny|Allow|ModifyAttribute; Match: -MatchPrefix, -MatchASNRange, -MatchCommunity; Set: -NewMED, -NewLocalPref, -NewNextHopChanges an existing policy (docs: RTPolicy01 MED -> 100)
Set-BgpRoutingPolicyForPeer-PeerName, -Direction Ingress|Egress, -PolicyNameClears earlier policies, applies the new set, restarts the session
PowerShell
Set-BgpRouteAggregate -Prefix "10.0.0.0/24" -SummaryOnly Enabled -PassThruSet-BgpRouteFlapDampening -HalfLife 600 -ReuseThreshold 500 `  -SuppressThreshold 2000 -PassThruSet-BgpRoutingPolicy -Name "RTPolicy01" -PolicyType ModifyAttribute -NewMED 100Set-BgpRoutingPolicyForPeer -Direction Ingress -PeerName "TenantSite03" `  -PolicyName "RTPolicy02", "RTPolicy04", "RTPolicy05"
Output
PS C:\> Set-BgpRoutingPolicyForPeer -Direction Ingress -PeerName "TenantSite03" -PolicyName "RTPolicy02", "RTPolicy04", "RTPolicy05"ConfirmBGP peering session could currently be active for TenantSite03. Do you want to apply these policies and restartcorresponding peering sessions?[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y

258.4 Lab: live BGP changes with FRRouting

Lab: n258-bgp
  1. 1.router1 AS 65001 (192.168.158.11) and router2 AS 65002 (192.168.158.12) on the n258-bgp bridge

  2. 2.router1 sends BGP UPDATE with lab-only routes 10.255.x.0/24 (blackhole statics)

  3. 3.router2 sends KEEPALIVE back

  4. 4.Each Set- idea is applied live and router2's table is compared before/after

FRR changeWindows ideaResult in the lab
neighbor ... timers 10 30Set-BgpPeer -HoldTimeSecConfigured 30 but negotiated hold stays 9 until router2 also uses 10 30
bgp router-id 192.168.158.101Set-BgpRouter -BgpIdentifierrouter2 sees the new remote router ID
aggregate-address 10.255.0.0/16 summary-onlySet-BgpRouteAggregate -SummaryOnly EnabledSpecifics marked s (suppressed); router2 keeps only the /16
route-map FROM-R1: set metric 200, local-preference 300 + clear soft inSet-BgpRoutingPolicyMetric 200, LocPrf 300 without breaking the session
bgp dampening 10 500 2000 40Set-BgpRouteFlapDampeningHalf-life 10 min, reuse 500, suppress 2000, max 40 min
Terminal
# router1vtysh -c 'configure terminal' -c 'router bgp 65001' \  -c 'neighbor 192.168.158.12 timers 10 30'vtysh -c 'clear ip bgp 192.168.158.12'vtysh -c 'configure terminal' -c 'router bgp 65001' \  -c 'bgp router-id 192.168.158.101'vtysh -c 'configure terminal' -c 'router bgp 65001' \  -c 'address-family ipv4 unicast' \  -c 'no aggregate-address 10.255.0.0/16' \  -c 'aggregate-address 10.255.0.0/16 summary-only'
Output
[router1]$ vtysh -c 'show bgp summary' | grep 'router identifier'BGP router identifier 192.168.158.11, local AS number 65001 VRF default vrf-id 0[router1]$ vtysh -c 'configure terminal' -c 'router bgp 65001' -c 'bgp router-id 192.168.158.101'[router1]$ vtysh -c 'show bgp summary' | grep 'router identifier'BGP router identifier 192.168.158.101, local AS number 65001 VRF default vrf-id 0[router2]$ vtysh -c 'show bgp neighbors 192.168.158.11' | grep ...  BGP version 4, remote router ID 192.168.158.101, local router ID 192.168.158.12  BGP state = Established, up for 00:00:15[router2]$ vtysh -c 'show ip bgp'    Network          Next Hop            Metric LocPrf Weight Path *> 10.255.0.0/16    192.168.158.11         100             0 65001 i *> 10.255.20.0/24   0.0.0.0                  0         32768 iDisplayed 2 routes and 2 total paths
Terminal
# router2vtysh -c 'configure terminal' -c 'route-map FROM-R1 permit 10' \  -c 'set metric 200' -c 'set local-preference 300'vtysh -c 'clear ip bgp 192.168.158.11 soft in'vtysh -c 'configure terminal' -c 'router bgp 65002' \  -c 'address-family ipv4 unicast' -c 'bgp dampening 10 500 2000 40'vtysh -c 'show ip bgp dampening parameters'
Output
[router2]$ vtysh -c 'show ip bgp dampening parameters'Half-life time: 10 minReuse penalty: 500Suppress penalty: 2000Max suppress time: 40 minMax suppress penalty: 8000

258.5 DirectAccess Set- cmdlets

NLS check: inside or outside?
  1. 1.On every network change the DA client requests https://nsl.corp.contoso.com

  2. 2.At home: the NLS is unreachable, check fails -> "I am outside"

  3. 3.Client builds an IP-HTTPS tunnel to the DA server 131.107.0.2 and reaches the corp LAN

  4. 4.In the office: the NLS replies 200 OK over HTTPS -> "I am inside"

  5. 5.Inside: DA rules stay off

If the NLS is down, even inside clients think they are outside: keep it highly available

CmdletWhat it changes
Set-DAAppServerConnection-ConnectionType NoE2EAuth|E2EAuthOnlyToAppServer|E2EAuthRequiredToAllServers, -TrafficProtection
Set-DAClient-ForceTunnel (all traffic via corp), -OnlyRemoteComputers (laptops only), -Downlevel (Windows 7)
Set-DAClientDnsConfigurationNRPT entry DNS server / -ProxyServer; -Local FallbackSecure|FallbackPrivate|FallbackUnsecure
Set-DAEntryPoint / Set-DAEntryPointDCRename, -GslbIP / -NewDC (-ExistingDC moves all its entry points)
Set-DAMultiSite-GslbFqdn, -ManualEntryPointSelectionAllowed
Set-DANetworkLocationServer-Url with -CheckReachability, -NlsOnDAServer, -Certificate
Set-DAOtpAuthenticationCA servers, certificate templates, -UserSecurityGroupName
Set-DAServer-DAInstallType, -ConnectToAddress, -TeredoState, -UserAuthentication TwoFactor|UserPasswd
PowerShell
Set-DAAppServerConnection -ConnectionType E2EAuthRequiredToAllServers `  -TrafficProtection Enabled -PassThruSet-DAClient -ForceTunnel "Enabled" -OnlyRemoteComputers "Enabled" -PassThruSet-DAClientDnsConfiguration -DnsSuffix 'contoso.com' `  -ProxyServer 'webproxy.contoso.com:400'Set-DAEntryPoint -Name "Entry Point 1" -GslbIP "10.1.2.44" -ForceSet-DAMultiSite -GslbFqdn "directaccessGlobalSite.contoso.com"Set-DANetworkLocationServer -Url https://nsl.corp.contoso.com -CheckReachability -PassThruSet-DAServer -DAInstallType FullInstall -PassThru
Output
PS C:\> Set-DAClient -ForceTunnel "Enabled" -OnlyRemoteComputers "Enabled" -PassThruOnlyRemoteComputers   : EnabledDownlevel    : DisabledForceTunnelingStatus  : EnabledForceTunnelingNrptSuffix  : .PS C:\>Set-DAMultiSite -GslbFqdn "directaccessGlobalSite.contoso.com" -PassTrueEnterpriseName                   : Company EnterpriseGslbFqdn                         : directaccessglobalsite.contoso.comManualEntryPointSelectionAllowed : EnabledDAEntryPoints                    : Entry Point 1PS C:\>Set-DAServer -DAInstallType FullInstall -PassThruConfirmIf the DirectAccess Configuration is changed to FullInstall, DirectAccess client computers will be able to connect to internal network via DirectAccess. Do you want to continue to change DAInstallType?[Y] Yes  [N] No  [S]Suspend [?] Help  (default is "Y"): YDAInstallType               : FullInstallInternetInterface           : internetInternalInterface           : datestConnectToAddress            : 131.107.0.2UserAuthentication          : UserPasswdTeredoState                 : Disabled

258.6 Set-RemoteAccess, accounting and IP filter

  • Set-RemoteAccess: settings common to DA and VPN: -InternalInterface, -InternetInterface, -SslCertificate (HTTPS for DA, SSTP for VPN).
  • Set-RemoteAccessConfiguration applies a config object from Get-CimInstance (-RestartServiceIfRequired).
  • Set-RemoteAccessIpFilter: -Action Allow|Deny on an interface/direction.
  • Set-RemoteAccessAccounting: -EnableAccountingType / -DisableAccountingType Inbox|ExternalRadius; external RADIUS on port 1813.
  • Set-RemoteAccessInboxAccountingStore -StoreLimit: default 12m, 2y = two years.
PowerShell
Set-RemoteAccess -InternalInterface 'DomainConnection' -InternetInterface 'Public Network'Set-RemoteAccessIpFilter -Action Allow -Direction Inbound `  -InterfaceAlias "Ethernet" -AddressFamily IPv4Set-RemoteAccessAccounting -EnableAccountingType ExternalRadius `  -RadiusServer radius1.corp.contoso.com -RadiusPort 1813 -RadiusTimeout 5 `  -SharedSecret s3cr3t -RadiusScore 30Set-RemoteAccessInboxAccountingStore -StoreLimit 2y -PassThru
Output
PS C:\>Set-RemoteAccessInboxAccountingStore -StoreLimit 2y -PassThruInboxAccountingStatus      : EnabledStoreLimit                 : 2yStoreUsedBytes             : 12648448StoreFreeBytesInPercentage : 99.70551StoreFirstRecordDate       : 29-11-2011 23:54:59StoreLastRecordDate        : 29-12-2011 15:37:45

258.7 Common mistakes

  • Thinking Set-Bgp* changes are zero-impact: peer/router/policy changes restart active sessions; use a maintenance window and soft refresh.
  • Setting hold time on one side only and expecting it to apply: BGP uses the smaller value of both sides.
  • Changing the NLS URL without -CheckReachability, or before clients get the new GPO (old GPO = old URL).
  • Forgetting Set-BgpRoutingPolicyForPeer replaces (clears) the earlier policies on that direction.

258.8 Interview tips

  • Hold time set to 30 but shows 9: it is negotiated, the smaller value wins; change both routers and restart the session.
  • DA clients think they are outside even inside: check NLS reachability from inside, fix with Set-DANetworkLocationServer -Url -CheckReachability, push new GPOs.
  • summary-only hides the specific routes; peers see only the aggregate.
  • Dampening knobs: half-life, reuse, suppress, max suppress time.