netsh – other contexts (3/3)
netsh contexts part 3: rpc (selective binding and RPC firewall filters), ras (Routing and Remote Access: VPN authentication, RADIUS, diagnostics, client IP addressing) and wcn (Windows Connect Now / WPS). A FreeRADIUS lab shows the RADIUS flow for real on Linux.
208.1 Why is it used?
- Limit which interfaces RPC listens on, and block specific RPC traffic with filters.
- Configure a Windows VPN server: authentication types, IKEv2/SSTP, ports, users.
- Send VPN authentication and accounting to a central RADIUS server (NPS).
- rpc and wcn exist on every Windows; ras really works only with the RRAS role on Windows Server; set/add need admin.
208.2 rpc: selective binding
- Step 1
1.Selective binding: RPC service listens only on 192.168.10.0
- Step 2
2.Office PC (192.168.10.20) sends an RPC call
- Step 3
3.File server replies
- Step 4
4.Guest laptop (192.168.50.30) sends an RPC call
- Step 5
5.Not bound on that subnet: no answer
netsh rpc ?netsh rpc filter ?C:\> netsh rpc ?Commands in this context:? - Displays a list of commands.add - Creates an Add list of subnets.delete - Creates a Delete list of subnets.dump - Displays a configuration script.filter - Changes to the `netsh rpc filter' context.reset - Resets the selective binding settings to 'none' (listen on all interfaces).show - Displays the selective binding state for each subnet on the system.C:\> netsh rpc filter ?add - Adds configuration entry to a table.delete - Deletes configuration entry from a table.help - Displays a list of commands.show - Displays information.netsh rpc add 192.168.1.0 Add list: listen only herenetsh rpc delete 192.168.1.0 Delete list: stop listening herenetsh rpc reset none: listen on all interfacesnetsh rpc show state of each subnetrpc show and filter show were not run on the office PC because they can reveal the security policy.
208.3 rpc filter: RPC firewall filters
- Step 1
1.add rule layer=um actiontype=block
- Step 2
2.add condition field=protocol matchtype=equal data=NCACN_IP_TCP
- Step 3
3.add filter combines the rule and its conditions (on top of WFP)
- Step 4
4.Office PC sends RPC over TCP
- Step 5
5.The call is dropped at the server: blocked by RPC filter
netsh rpc filter add rule layer=um actiontype=blocknetsh rpc filter add condition field=protocol matchtype=equal data=NCACN_IP_TCPnetsh rpc filter add filter netsh rpc filter delete filter filterkey=all| Part | Options |
|---|---|
| Rule | layer=um|epmap|ep_add|proxy_conn|proxy_if, actiontype=block|permit|continue, filterkey, persistence=volatile, audit |
| Condition | field=if_uuid|if_version|protocol|remote_addr_v4|local_port|opnum..., matchtype=equal|greater|less|range|... |
| Manage | add filter, delete filter filterkey=<uuid>|all, delete rule, show filter |
208.4 ras: Remote Access server
- Step 1
1.Employee's home laptop starts a VPN connection
- Step 2
2.Request crosses the internet to RRAS (192.168.10.1)
- Step 3
3.Server negotiates authentication: MSCHAPv2, EAP or IKEv2 certificate
- Step 4
4.PPP link options (SWC, LCP, multilink) are negotiated
- Step 5
5.RRAS may hand the password check to RADIUS (NPS, 192.168.10.5)
C:\> netsh ras ?Commands in this context:aaaa - Changes to the `netsh ras aaaa' context.add - Adds items to a table.delete - Removes items from a table.diagnostics - Changes to the `netsh ras diagnostics' context.dump - Displays a configuration script.ip - Changes to the `netsh ras ip' context.ipv6 - Changes to the `netsh ras ipv6' context.set - Sets configuration information.show - Displays information.The following sub-contexts are available: aaaa diagnostics ip ipv6netsh ras add authtype type=MSCHAPv2netsh ras delete authtype type=PAPnetsh ras add multilink type=MULTInetsh ras add registeredserver server=RAS01netsh ras set ikev2saexpiry saexpirytime=3600 sadatasizelimit=1073741824netsh ras set ikev2connection idletimeout=30 nwoutagetime=5netsh ras set sstp-ssl-cert hash=<sha1>netsh ras set client name=jdoe state=disconnectnetsh ras show confnetsh ras show portstatus state=connectedrem netsh ras> context prompt:set user user1 dialin=permit cbpolicy=admin cbnumber=4255550110| Area | Commands | What it sets |
|---|---|---|
| Authentication | add/delete authtype PAP|MD5CHAP|MSCHAPv2|EAP|CERT | Types the server negotiates |
| PPP | add link SWC|LCP, add multilink MULTI|BACP | Compression, LCP extensions, multilink |
| Server | set authmode, set conf, set type, add registeredserver | Who must authenticate, enabled, router/RAS role, AD registration |
| IKEv2 / SSTP | set ikev2connection, set ikev2saexpiry, set sstp-ssl-cert | Idle timeout, SA lifetime, SSTP certificate |
| Ports / users | show portstatus state=..., set user dialin= cbpolicy=, set wanports | Port status, dial-in and callback, WAN Miniport options |
No ras show command was run on the office PC: it could reveal the office VPN settings. Docs examples have no output, so only syntax is shown.
208.5 ras aaaa: RADIUS authentication and accounting
- Step 1
1.RRAS sends Access-Request to RADIUS (UDP 1812)
- Step 2
2.RADIUS checks the user and the shared secret
- Step 3
3.RADIUS returns Access-Accept
- Step 4
4.After connect, RRAS sends Accounting Start (UDP 1813)
- Step 5
5.RADIUS keeps a record of who connected when
netsh ras aaaa set authentication provider=RADIUSnetsh ras aaaa set accounting provider=RADIUSnetsh ras aaaa add authserver name=radius1.contoso.com secret=S3cret port=1812 timeout=5 signature=ENABLEDnetsh ras aaaa add acctserver name=AcctSrv1 secret=P@ssw0rd init-score=50 port=1813 timeout=30 messages=ENABLEDnetsh ras aaaa delete authserver name=AuthSrv1- provider decides whether Windows or RADIUS does authentication and accounting.
- init-score = priority; signature=ENABLED adds Message-Authenticator; timeout marks a server unavailable.
208.6 Linux lab: FreeRADIUS
radius container = FreeRADIUS server (192.168.228.10), nas container = the VPN server (192.168.228.20).
radiusd -v | head -1tail -6 /etc/raddb/clients.confhead -3 /etc/raddb/mods-config/files/authorize$ radiusd -v | head -1radiusd: FreeRADIUS Version 3.0.27, for host x86_64-alpine-linux-musl$ tail -6 /etc/raddb/clients.confclient n208-nas { ipaddr = 192.168.228.20 secret = lab-n208-secret shortname = vpn-server}$ head -3 /etc/raddb/mods-config/files/authorizestudent Cleartext-Password := "lab-pass-208" Reply-Message := "Welcome to the n208 VPN lab"radtest student lab-pass-208 192.168.228.10 0 lab-n208-secretradtest student wrong-pass 192.168.228.10 0 lab-n208-secret$ radtest student lab-pass-208 192.168.228.10 0 lab-n208-secretSent Access-Request Id 67 from 0.0.0.0:55373 to 192.168.228.10:1812 length 77 User-Name = "student" NAS-IP-Address = 192.168.228.20Received Access-Accept Id 67 from 192.168.228.10:1812 to 192.168.228.20:55373 length 67 Reply-Message = "Welcome to the n208 VPN lab"(exit 0)$ radtest student wrong-pass 192.168.228.10 0 lab-n208-secretSent Access-Request Id 14 from 0.0.0.0:60937 to 192.168.228.10:1812 length 77 User-Password = "wrong-pass"(0) -: Expected Access-Accept got Access-RejectReceived Access-Reject Id 14 from 192.168.228.10:1812 to 192.168.228.20:60937 length 67(exit 1)A="User-Name=student,Acct-Status-Type=Start"A="$A,Acct-Session-Id=n208-0001"A="$A,NAS-IP-Address=192.168.228.20"echo "$A" | radclient -x 192.168.228.10:1813 acct lab-n208-secret# radius: cd .../radacct/192.168.228.20cat detail-*B="User-Name=student,User-Password=lab-pass-208"echo "$B" | radclient -r 1 -t 3 -x 192.168.228.10 auth wrong-secret$ echo "$A" | radclient -x 192.168.228.10:1813 acct lab-n208-secretSent Accounting-Request Id 188 from 0.0.0.0:32920 to 192.168.228.10:1813 length 52 Acct-Status-Type = Start Acct-Session-Id = "n208-0001"Received Accounting-Response Id 188 from 192.168.228.10:1813 to 192.168.228.20:32920 length 20(exit 0)[radius] $ cat detail-*Mon Nov 9 13:19:44 2026 User-Name = "student" NAS-IP-Address = 192.168.228.20 Event-Timestamp = "Nov 9 2026 13:19:44 UTC"$ echo "$B" | radclient -r 1 -t 3 -x 192.168.228.10 auth wrong-secretSent Access-Request Id 103 from 0.0.0.0:46931 to 192.168.228.10:1812 length 65(0) No reply from server for ID 103 socket 3(exit 1)[radius debug] Dropping packet without response because of error: Received packet from 192.168.228.20 with invalid Message-Authenticator! (Shared secret is incorrect.) (from client vpn-server)- Correct password: Access-Accept with the Reply-Message; wrong password: Access-Reject, exit 1.
- Accounting Start gets an Accounting-Response and is saved in the detail file with the session id.
- Wrong shared secret: the server silently drops the packet (invalid Message-Authenticator), so the client sees no reply.
208.7 ras diagnostics and ras ip / ipv6
netsh ras diagnostics set loglevel events=warnrem netsh ras diagnostics> prompt:show all type=file destination="c:\test\rasdiag.htm"netsh ras ip set addrassign method=POOLnetsh ras ip add range from=192.168.50.10 to=192.168.50.50netsh ras ip set access mode=ALLnetsh ras ip set preferredadapter name="Ethernet 2"netsh ras ipv6 set prefix prefix=2001:0db8:85a3::/64- diagnostics: set rastracing / loglevel / tracefacilities; show all type=file|email saves a report (HTML or CAB).
- addrassign POOL = static pool from RRAS; AUTO = addresses from DHCP.
- access mode ALL = client reaches the whole office LAN; SERVERONLY = only the server.
- ipv6: set prefix and routeradvertise for clients.
208.8 wcn: Windows Connect Now (WPS)
C:\> netsh wcn ?Commands in this context:? - Displays a list of commands.dump - Displays a configuration script.enroll - Connects to a wireless network.help - Displays a list of commands.query - Queries information about a WCN device.netsh wcn enroll enrolleeUUID="01234567-89AB-..." password="12345670" profile="MySSID_Network" interface="Wi-Fi" type=autonetsh wcn query SSID="MySSID" interface="Wi-Fi"enroll takes the device's WPS UUID and PIN plus a Wi-Fi profile; type = auto | ethernet | 802dot11. query was not run because it fetches details of nearby access points.
208.9 Comparison: VPN authentication types
| Type | Security | Recommendation |
|---|---|---|
| PAP | Password in clear text | Disable: delete authtype type=PAP |
| MD5CHAP | Challenge-response with MD5 | Legacy, avoid |
| MSCHAPv2 | Password-based challenge-response | Acceptable, but not the best |
| EAP | Pluggable methods (certs, smart cards) | Preferred |
| CERT (IKEv2) | Machine/user certificate | Preferred |
208.10 Common mistakes
- Thinking blocking port 135 controls RPC: RPC also uses dynamic ports and named pipes; use an RPC filter on if_uuid + protocol.
- Leaving PAP enabled on a VPN server.
- Weak or mismatched RADIUS shared secret: wrong secret = packets dropped with no reply.
- Using a volatile RPC filter and expecting it to survive a reboot.
208.11 Interview tips
- Central password check + connect-time records: netsh ras aaaa with provider=RADIUS, authserver and acctserver.
- RADIUS ports: 1812 authentication, 1813 accounting.
- Prefer EAP or IKEv2 certificates over MSCHAPv2; never PAP.
- RPC filter = rule + condition + filter, built on WFP.