netsh – other contexts (2/3)
netsh contexts part 2: encrypted DNS (DoH, DoT, DDR) in dnsclient, NRPT (namespace), WFP diagnostics, network bridge, mobile broadband (mbn), binding filters (netio), Network List Manager (nlm) and BranchCache. All are built into netsh.exe; set/add need an elevated prompt.
207.1 Why is it used?
- Encrypt DNS so the ISP or a cafe Wi-Fi cannot read which sites you look up.
- Send corporate namespaces to the office DNS (VPN, DirectAccess) via NRPT.
- Find which WFP filter silently dropped an app's packets (firewall, IPsec, antivirus, VPN).
- Bridge two adapters, manage cellular modems, cut branch-office WAN traffic.
- mbn needs a cellular modem and branchcache needs the BranchCache feature; Linux/macOS have no netsh.
207.2 Help output (real, office PC)
netsh dnsclient ?netsh namespace ?netsh wfp ?netsh wfp show ?C:\> netsh namespace ?? - Displays a list of commands.help - Displays a list of commands.C:\> netsh wfp ?capture - Captures real-time diagnostic information.set - Sets WFP diagnostic options.show - Shows WFP configuration and state.C:\> netsh wfp show ?show appid - Displays the application ID for the specified file.show boottimepolicy - Displays the boot-time policy and filters.show filters - Displays filters matching the specified traffic parameters.show ikeevents - Displays recent IKE epoch events matching the specified parameters.show netevents - Displays recent network events matching the traffic parameters.show options - Displays the global WFP options.show security - Displays the specified security descriptor.show state - Displays the current state of WFP and IPsec.show sysports - Displays system ports used by the TCP/IP Stack and the RPC sub-system.- namespace has only dump and show: netsh can read NRPT but not set it.
- NRPT, DoH settings and WFP filters would reveal office policy, so those examples come from Microsoft Learn.
207.3 Encrypted DNS: DoH, DoT, DDR
- Step 1
1.Laptop (192.168.1.10) sends a normal DNS query on UDP 53
- Step 2
2.ISP / Wi-Fi in between can read example.com
- Step 3
3.Same question via DoH goes inside HTTPS on 443 (DoT: TLS on 853)
- Step 4
4.The network in between sees only TLS bytes
- Step 5
5.Resolver 1.1.1.1 answers; Windows settings come from netsh dnsclient
netsh dnsclient add encryption server=<IP> dohtemplate=<url> dothost=<host>:<port> autoupgrade=yes udpfallback=nonetsh dnsclient show encryption [server=<IP>]netsh dnsclient set global doh=yes|no|auto auto = well-known servers use only DoHnetsh dnsclient set global dot=yes|nonetsh dnsclient set global ddr=yes|nonetsh dnsclient show global | show state| Point | Plain DNS | DoT | DoH |
|---|---|---|---|
| Transport | UDP/TCP 53 | TLS on TCP 853 | HTTPS on 443 |
| Visible on path | Query name in clear | Only TLS bytes | Only TLS bytes (looks like web traffic) |
| Easy to block | - | Yes (own port) | Hard (shares 443) |
| netsh switch | - | dothost, set global dot | dohtemplate, set global doh |
Linux lab (equivalent, not netsh): resolver 192.168.227.10 runs unbound + dnsdist with no internet upstream.
timeout 8 tcpdump -nn -l -A -i eth0 'host 192.168.227.10 and port 53' > /tmp/plain.cap &dig +noall +answer +stats @192.168.227.10 web.lab.exampletimeout 8 tcpdump -nn -l -A -i eth0 'host 192.168.227.10 and port 853' > /tmp/dot.cap &dig +tls +tls-ca=/tmp/lab-ca.pem +tls-hostname=dns.lab.example +noall +answer +stats @192.168.227.10 web.lab.example$ dig +noall +answer +stats @192.168.227.10 web.lab.exampleweb.lab.example. 300 IN A 192.168.227.20;; SERVER: 192.168.227.10#53(192.168.227.10) (UDP)$ grep -c web.lab.example /tmp/plain.cap313:09:36.766623 IP 192.168.227.20.47069 > 192.168.227.10.53: 50074+ [1au] A? web.lab.example. (56)$ dig +tls ... @192.168.227.10 web.lab.example;; SERVER: 192.168.227.10#853(192.168.227.10) (TLS)name in clear: 0dig +https +tls-ca=/tmp/lab-ca.pem +tls-hostname=dns.lab.example +noall +answer +stats @192.168.227.10 web.lab.examplecurl -sv --cacert /tmp/lab-ca.pem --doh-url https://192.168.227.10/dns-query http://web.lab.example:8080/dig +noall +answer @192.168.227.10 _dns.resolver.arpa SVCBdig @192.168.227.10 example.com$ dig +https ... @192.168.227.10 web.lab.exampleweb.lab.example. 300 IN A 192.168.227.20;; SERVER: 192.168.227.10#443(192.168.227.10) (HTTPS)$ curl -sv ... --doh-url https://192.168.227.10/dns-query ...* IPv4: 192.168.227.20* Connected to web.lab.example (192.168.227.20) port 8080< HTTP/1.0 200 OKhello from web.lab.example$ tcpdump during curl (host 192.168.227.10)port 53: 0 packets, port 443: 23 packets$ dig +noall +answer @192.168.227.10 _dns.resolver.arpa SVCB_dns.resolver.arpa. 300 IN SVCB 1 dns.lab.example. alpn="dot" port=853_dns.resolver.arpa. 300 IN SVCB 2 dns.lab.example. alpn="h2" port=443 key7="/dns-query{?dns}"$ dig @192.168.227.10 example.com;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 29978- Plain UDP: the name appears 3 times in the capture; DoT: 0 times.
- curl --doh-url resolved over DoH: 0 packets on port 53, 23 on 443.
- DDR: SVCB records at _dns.resolver.arpa tell the client the same resolver also speaks DoT (853) and DoH (443).
- Names outside the lab get REFUSED because the resolver has no upstream.
207.4 NRPT: DNS server by namespace
- Step 1
1.NRPT rule: .corp.example -> 192.168.50.53
- Step 2
2.Laptop asks app.corp.example -> goes to the office DNS
- Step 3
3.Laptop asks example.com -> goes to the public resolver 1.1.1.1
- Step 4
4.VPN and DirectAccess use this same table
- Step 5
5.If the NRPT server supports DoH, that query can go over DoH
netsh namespace show policy [namespace=<string>]netsh namespace show effectivepolicy [namespace=<string>]netsh namespace dumpshow policy lists configured entries; show effectivepolicy shows what actually applies now.
207.5 WFP: who dropped the packet?
- Step 1
1.app.exe sends a DNS query to 8.8.8.8
- Step 2
2.A WFP filter inside Windows drops it
- Step 3
3.The user only sees "Request timed out"
- Step 4
4.netsh wfp show netevents writes the DROP with its filter ID to netevents.xml
- Step 5
5.netsh wfp show filters shows which filter matches that traffic
netsh wfp capture start [cab=on|off] [file=<path>] creates wfpdiag.cabnetsh wfp capture stopnetsh wfp set options netevents=on start buffering dropsnetsh wfp show netevents [timewindow=<sec>] netevents.xmlnetsh wfp show filters protocol=17 remoteport=53 dir=out [file=-]netsh wfp show appid file=<path>netsh wfp show state | show sysports | show boottimepolicy- WFP is the filtering engine under Windows Firewall, IPsec and many antivirus/VPN products.
- Filters for show filters/netevents: protocol, local/remote addr and port, appid, userid, dir; file=- prints to console.
207.6 Bridge
netsh bridge create adapter=1 adapter=2netsh bridge listnetsh bridge add <Adapter ID> to <Bridge GUID>netsh bridge remove <Adapter ID> from <Bridge GUID>netsh bridge destroy <Bridge GUID>C:\> netsh bridge ?add - Add a network adapter onto an existing bridge.create - Create a bridge with two user-provided network adapters.destroy - Remove ALL bridged network adapters from the existing bridge and destroy that bridge.list - Display all available created bridges.remove - Remove network adapter(s) from a bridge, and destroy the bridge when all network adapters are removed.show - Displays information.- A bridge makes Ethernet + Wi-Fi one Layer 2 segment: a Wi-Fi laptop (192.168.1.30) reaches an Ethernet printer (192.168.1.20) in the same subnet with no router.
- list gives each bridge's GUID; add, remove and destroy work on that GUID.
ip link add br-lab type bridgeip link add veth-a type veth peer name veth-bip link set veth-a master br-labip link set veth-a up; ip link set veth-b up; ip link set br-lab upip -br link show type bridgebridge link showip link del veth-a; ip link del br-lab$ ip -br link show type bridgebr-lab UP 4e:18:00:69:b8:d9 <BROADCAST,MULTICAST,UP,LOWER_UP>$ bridge link show5: veth-a@veth-b: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br-lab state forwarding priority 32 cost 2$ ip link del veth-a; ip link del br-lab; ip -br linklo UNKNOWN 00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>eth0@if1569 UP 5a:13:ad:aa:b6:ec <BROADCAST,MULTICAST,UP,LOWER_UP>207.7 mbn, netio and nlm
netsh mbn show interfacesnetsh mbn add profile interface=<if> name=<xml>netsh mbn connect interface=Cellular connmode=tmp name=temp_profile.xmlnetsh mbn set acstate state=autoon|autooff|manualon|manualoffnetsh mbn set dataroamcontrol state=none|partner|allnetsh mbn set powerstate state=on|offnetsh mbn set profileparameter cost=default|unrestricted|fixed|variablenetsh mbn show signal | show connection | show readyinfo- Always start with show interfaces: other mbn commands need the interface name (quote it if it has spaces).
- dataroamcontrol none = home carrier only; profile cost marks a metered connection.
netsh netio add bindingfilter npi="NPI_Name" client="Client_Name" provider="Provider_Name" type=block store=persistentnetsh netio show bindingfilters [store=persistent]netsh nlm show connectivity | show costnetsh nlm query all <file>netsh nlm set connectionquality <My_GUID> good- netio binding filters decide which client may bind to which provider; store=active is lost on reboot, persistent stays.
- nlm shows connectivity and cost; set connectionquality marks an interface good, bad or ignore.
207.8 BranchCache
- Step 1
1.PC 1 downloads report.pdf from the HQ server over the WAN
- Step 2
2.PC 1 keeps it in its local cache
- Step 3
3.PC 2 asks for the same file; HQ sends only content info (hashes) over the WAN
- Step 4
4.PC 2 gets the actual data from PC 1 over the LAN
- Step 5
5.Distributed mode = peers; hosted cache mode = a branch server does this
netsh branchcache set service mode=DISTRIBUTEDnetsh branchcache set service mode=HOSTEDCLIENT location=<host>netsh branchcache set cachesize size=<n> percent=TRUEnetsh branchcache show status detail=ALLnetsh branchcache flush | resetnetsh branchcache exportkey | importkeynetsh branchcache smb set latency=80| Mode | Meaning |
|---|---|
| DISABLED / LOCAL | Off / cache only for this PC |
| DISTRIBUTED | Peers in the branch share their caches |
| HOSTEDSERVER | This machine is the branch hosted cache server |
| HOSTEDCLIENT | Clients use the hosted cache at location=<host> |
207.9 Common mistakes
- Thinking DoH means full privacy: the resolver still sees every query.
- Leaving udpfallback=yes: a failed DoH query silently goes out as plain UDP.
- Trying to set NRPT with netsh namespace: it is read-only; use Group Policy or PowerShell.
- Blaming the network for timeouts before checking WFP netevents.
207.10 Interview tips
- DoH = DNS in HTTPS (443), DoT = DNS in TLS (853); DDR = discovery via _dns.resolver.arpa SVCB.
- "corp names go to office DNS on VPN" = NRPT; check with netsh namespace show effectivepolicy.
- Silent drops on Windows: netsh wfp show netevents, then show filters.
- BranchCache sends hashes over the WAN and data over the LAN.