SkillPilotAI

netsh interface (5/5)

The last part of netsh interface: the remaining portproxy types (v4tov6, v6tov4, v6tov6) with set and delete, the ISATAP and Teredo tunnel contexts, and the tcp and udp contexts where Windows TCP tuning (autotuning, RTO, templates, offloads) lives.

36.1 Where it runs

  • Windows only, in CMD and PowerShell. show and help as a normal user; add, set and delete need Run as administrator.
  • Linux equivalents: socat or iptables for portproxy, sysctl (and route options) for TCP settings.
  • Only show and help were run on the office PC; forwarding was done in a Docker lab.

36.2 portproxy add v4tov6, v6tov4, v6tov6

add v6tov4: IPv6 client to an IPv4-only server
  1. 1.Web server 192.168.56.20 serves only IPv4 on port 80; the client has only IPv6

  2. 2.add v6tov4 on the Windows PC listens on IPv6 port 8080

  3. 3.Client's request reaches the Windows PC over IPv6

  4. 4.portproxy opens a new IPv4 connection to 192.168.56.20:80 and relays the data

  5. 5.Server sees the request as coming from the Windows PC

  • Name = listen version 'to' connect version: v4tov6 listens on IPv4 and connects to IPv6.
  • listenport and connectaddress are required; no connectport means the listen port is used.
  • No listenaddress means all local addresses; protocol supports only TCP.
Terminal
netsh interface portproxy add v4tov6 ^  listenport=8080 listenaddress=0.0.0.0 ^  connectaddress=2001:db8::10 connectport=80 netsh interface portproxy add v6tov4 ^  listenport=8080 listenaddress=:: ^  connectaddress=192.168.56.20 connectport=80 netsh interface portproxy add v6tov6 ^  listenport=8080 connectaddress=2001:db8::10
Output
$ netsh interface portproxy add v6tov4 ?Usage: add v6tov4 [listenport=]<integer>|<servicename>            [[connectaddress=]<IPv4 address>|<hostname>]            [[connectport=]<integer>|<servicename>]            [[listenaddress=]<IPv6 address>|<hostname>]            [[protocol=]tcp]       listenport     - IPv6 port on which to listen.       connectaddress - IPv4 address to which to connect.       protocol       - Protocol to use.  Currently only TCP is supported.Remarks: Adds an entry to listen on for IPv6 and proxy connect to via IPv4.
TypeListens onConnects toLab socat listener
v4tov4IPv4IPv4TCP4-LISTEN:8044 -> TCP4:192.168.56.20:80
v4tov6IPv4IPv6TCP4-LISTEN:8046 -> TCP6:[fd00:56::20]:80
v6tov4IPv6IPv4TCP6-LISTEN:8064 -> TCP4:192.168.56.20:80
v6tov6IPv6IPv6TCP6-LISTEN:8066 -> TCP6:[fd00:56::20]:80

36.3 Practical: all four combinations with socat

Terminal
# proxy 192.168.56.5socat TCP4-LISTEN:8044,fork \  TCP4:192.168.56.20:80socat TCP4-LISTEN:8046,fork \  TCP6:[fd00:56::20]:80socat TCP6-LISTEN:8064,ipv6only=1,fork \  TCP4:192.168.56.20:80socat TCP6-LISTEN:8066,ipv6only=1,fork \  TCP6:[fd00:56::20]:80ss -ltnp# client 192.168.56.10curl -s http://192.168.56.5:8044curl -s http://192.168.56.5:8046curl -s -g http://[fd00:56::5]:8064curl -s -g http://[fd00:56::5]:8066
Output
$ ss -ltnpState  Recv-Q Send-Q Local Address:Port  Peer Address:PortLISTEN 0      5            0.0.0.0:8046       0.0.0.0:*LISTEN 0      5            0.0.0.0:8044       0.0.0.0:*LISTEN 0      5               [::]:8066          [::]:*LISTEN 0      5               [::]:8064          [::]:*$ curl -s http://192.168.56.5:8044web sees [0000:0000:0000:0000:0000:ffff:c0a8:3805]$ curl -s http://192.168.56.5:8046web sees [fd00:0056:0000:0000:0000:0000:0000:0005]$ curl -s -g http://[fd00:56::5]:8064web sees [0000:0000:0000:0000:0000:ffff:c0a8:3805]$ curl -s -g http://[fd00:56::5]:8066web sees [fd00:0056:0000:0000:0000:0000:0000:0005]

The web server always sees the proxy (192.168.56.5 as the IPv4-mapped ::ffff:c0a8:3805, or fd00:56::5), never the client.

36.4 portproxy set, delete, show all, reset

  • set v4tov4/v4tov6/v6tov4/v6tov6 updates an existing entry with the same options as add.
  • An entry is identified by listenport + listenaddress, so delete needs only those two.
  • show all lists every rule (empty on this PC); reset removes all rules at once.
Terminal
netsh interface portproxy set v4tov4 ^  listenport=8080 ^  connectaddress=192.168.56.20 ^  connectport=8000 netsh interface portproxy delete v6tov6 ^  listenport=8080 listenaddress=:: netsh interface portproxy show allnetsh interface portproxy reset
Output
$ netsh interface portproxy set v4tov4 ?Usage: set v4tov4 [listenport=]<integer>|<servicename>             [connectaddress=]<IPv4 address>|<hostname>            [[connectport=]<integer>|<servicename>]            [[listenaddress=]<IPv4 address>|<hostname>]            [[protocol=]tcp]Remarks: Updates an entry to listen on for IPv4 and proxy connect to via IPv4.$ netsh interface portproxy delete v4tov4 ?Usage: delete v4tov4 [listenport=]<integer>|<servicename>            [[listenaddress=]<IPv4 address>|<hostname>]            [[protocol=]tcp]Remarks: Deletes an entry to listen on for IPv4 and proxy connect to via IPv4.
Terminal
# set v4tov4: connectport 80 -> 8000pkill -f TCP4-LISTEN:8044socat TCP4-LISTEN:8044,fork \  TCP4:192.168.56.20:8000curl -s http://192.168.56.5:8044# delete v6tov6pkill -f TCP6-LISTEN:8066curl -sS -g http://[fd00:56::5]:8066ss -ltn
Output
$ curl -s http://192.168.56.5:8044web v2 on 8000$ curl -sS -g http://[fd00:56::5]:8066curl: (7) Failed to connect to fd00:56::5 port 8066 after 10 ms: Couldn't connect to server$ ss -ltnState  Recv-Q Send-Q Local Address:Port  Peer Address:PortLISTEN 0      5            0.0.0.0:8046       0.0.0.0:*LISTEN 0      5            0.0.0.0:8044       0.0.0.0:*LISTEN 0      5               [::]:8064          [::]:*

36.5 isatap and teredo contexts

Teredo: IPv6 from behind NAT
  1. 1.PC has no native IPv6 and sits behind NAT

  2. 2.Teredo wraps the IPv6 packet inside an IPv4 UDP packet

  3. 3.The UDP packet passes through the NAT

  4. 4.Teredo server unwraps it and sends it on to the IPv6 internet

ISATAP is a similar tunnel over a company's IPv4 network; both are deprecated

Terminal
netsh interface isatap show statenetsh interface isatap show routernetsh interface teredo show state
Output
$ netsh interface isatap show stateISATAP State           : default$ netsh interface isatap show routerRouter Name            : defaultUse Relay              : defaultResolution Interval    : default$ netsh interface teredo show stateTeredo Parameters---------------------------------------------Type                    : disabledServer Name             : win1910.ipv6.microsoft.com.Client Refresh Interval : 30 secondsClient Port             : unspecifiedState                   : offlineError                   : none
Output
isatap set state  enabled|disabled|defaultisatap set router name=isatap.example.com  state=enabled  name resolution on  interval=1440  resolve every 1440 minisatap show state | show router | dumpteredo set state type=...  disabled         Teredo off  client           normal client  enterpriseclient managed check skip  natawareclient   also finds NAT type  server           server SKU onlyservername=...  refreshinterval=60 (sec)clientport=34567  servervirtualip=IPv4teredo show state | dump

36.6 tcp context and set global

  • Special commands: reset (all TCP parameters to default), rundown (connection details into an active trace), reload (experimental, do not use).
  • show global on this PC: RSS enabled, autotuning normal, initial RTO 1000 ms, Fast Open/HyStart/PRR enabled, ECN disabled.
  • show global store=persistent: no persistent settings, so every value is the system default.
  • autotuninglevel lets the receive window grow to suit the network; initialrto and maxsynretransmissions control SYN retries.
Terminal
netsh interface tcp show globalnetsh interface tcp show global ^  store=persistent
Output
$ netsh interface tcp show globalReceive-Side Scaling State          : enabledReceive Window Auto-Tuning Level    : normalAdd-On Congestion Control Provider  : defaultECN Capability                      : disabledRFC 1323 Timestamps                 : allowedInitial RTO                         : 1000Receive Segment Coalescing State    : enabledMax SYN Retransmissions             : 4Fast Open                           : enabledHyStart                             : enabledProportional Rate Reduction         : enabledPacing Profile                      : off$ netsh interface tcp show global store=persistentQuerying persistent storage...No persistent TCP global settings have been found.
Output
rss=enabled|disabled     multi-core receiveautotuninglevel=normal   receive window  disabled|highlyrestricted|restricted|...ecncapability=enabled    congestion signaltimestamps=enabled       RFC 1323 timestampsinitialrto=1000          SYN retry (300-3000)maxsynretransmissions=4  SYN retries (2-8)rsc=enabled              segments combinenonsackrttresiliency=    non-SACK RTTfastopen=enabled         TCP Fast Openfastopenfallback=enabled Fast Open fallbackhystart=enabled          slow start exitprr=enabled              rate reductionpacingprofile=off|initialwindow|slowstarthar option: enabled|disabled|default

36.7 heuristics, security and supplemental templates

  • Window scaling heuristics are not supported in this Windows version; only forcews (force window scaling on retransmit) matters.
  • security: Memory Pressure Protection and Profiles enabled; protect TCP memory during a DoS. startport/numberofports apply it to a range.
  • Supplemental templates: default internet (min RTO 300 ms, delayed ACK 40 ms); datacenter (min RTO 60 ms, delayed ACK 10 ms) because DC latency is tiny. Both use cubic, ICW 10.
  • add supplementalport / supplementalsubnet map traffic (e.g. 10.10.0.0/16) to a template, new connections only; mostly on Windows Server (not supported on this PC).
Terminal
netsh interface tcp show heuristicsnetsh interface tcp show securitynetsh interface tcp set security ^  mpp=enabled startport=443 numberofports=1netsh interface tcp show supplementalnetsh interface tcp show supplemental ^  template=datacenter
Output
$ netsh interface tcp show heuristicsWindow Scaling heuristics         : disabledQualifying Destination Threshold  : 3Profile type public               : normal$ netsh interface tcp show securityMemory Pressure Protection        : enabledProfiles                          : enabled$ netsh interface tcp show supplementalThe TCP global default template is internetMinimum RTO (msec)                  : 300Initial Congestion Window (MSS)     : 10Congestion Control Provider         : cubicDelayed ACK timeout (msec)          : 40Delayed ACK frequency               : 2Enable RACK                         : enabledEnable Tail Loss Probe              : enabled$ netsh interface tcp show supplemental template=datacenterMinimum RTO (msec)                  : 60Initial Congestion Window (MSS)     : 10Congestion Control Provider         : cubicDelayed ACK timeout (msec)          : 10Delayed ACK frequency               : 2
Output
set supplemental template=internet  template=automatic|datacenter|compat|custom  minrto=20..300       min retransmit (ms)  icw=2..64            initial cwnd (MSS)  congestionprovider=cubic|ctcp|dctcp|bbr2  enablecwndrestart    restart after idle  delayedacktimeout=40 / delayedackfrequency=2  rack / taillossprobe loss recoveryadd supplementalport datacenter 10000 *add supplementalsubnet datacenter ipv4 ^  10.10.0.0/16delete supplementalport 80 *delete supplementalsubnet ipv4 10.10.0.0/16show supplementalports (here: not supported)

36.8 udp context

  • URO (receive offload) combines small UDP packets on receive.
  • USO (send offload) hands one big buffer to the NIC, which cuts it into packets.
  • Both enabled here; set global uro=/uso= enabled|disabled|default; reset restores defaults.
Output
$ netsh interface udp show globalUDP Global Parameters----------------------------------------------Receive Offload State               : enabledSend Offload State                  : enabled

36.9 Practical: the same TCP settings on Linux

  • Linux keeps TCP settings in sysctl; congestion control is cubic here too.
  • The Linux twin of supplementalsubnet: put TCP options on a route (rto_min 60ms, initcwnd 10).
  • ss on a live connection shows rto:64 and cwnd:10, proving the route options applied.
Terminal
sysctl net.ipv4.tcp_congestion_control \  net.ipv4.tcp_ecn net.ipv4.tcp_timestamps \  net.ipv4.tcp_fastopen \  net.ipv4.tcp_syn_retries \  net.ipv4.tcp_window_scalingip route add 192.168.56.20/32 dev eth0 \  rto_min 60ms initcwnd 10ip route show 192.168.56.20ss -tin dst 192.168.56.20 \  | grep -oE 'cubic|rto:[0-9]+|cwnd:[0-9]+'
Output
net.ipv4.tcp_congestion_control = cubicnet.ipv4.tcp_ecn = 2net.ipv4.tcp_timestamps = 1net.ipv4.tcp_fastopen = 1net.ipv4.tcp_syn_retries = 6net.ipv4.tcp_window_scaling = 1$ ip route show 192.168.56.20192.168.56.20 dev eth0 scope link initcwnd 10 rto_min lock 60ms$ ss -tin dst 192.168.56.20 | grep -oE 'cubic|rto:[0-9]+|cwnd:[0-9]+'cubicrto:64cwnd:10

36.10 Common mistakes

  • Disabling autotuning to 'speed up' the internet: it fixes the receive window and makes high-latency downloads slower. Keep normal; check show global first and change one thing at a time.
  • Mixing up the portproxy name order: listen side first, connect side second.
  • Expecting portproxy to handle UDP: TCP only.
  • Using tcp reload: the help itself says experimental, do not use.

36.11 Interview tips

  • IPv4-only client, IPv6-only server -> portproxy add v4tov6.
  • Forward a port on Windows: admin prompt, portproxy add v4tov4 listenport connectaddress connectport, firewall rule, IP Helper service, TCP only, verify with show all, clean up with delete.
  • Datacenter TCP template uses a much lower min RTO (60 ms vs 300 ms) because DC latency is low.
  • URO/USO are UDP offloads; RSS spreads receive work across CPU cores.