SkillPilotAI

netsh interface (2/5): IPv4 set and show

netsh interface ipv4 set commands change the Windows IPv4 stack (default TTL, port ranges, forwarding, MTU, DNS, routes) and the show commands read the same settings back. show ipstats and tcpstats are also among the most useful Windows troubleshooting counters.

33.1 What it does and where it runs

  • set = change IPv4 stack settings; show = read and display them.
  • Windows only. Every set needs an admin Command Prompt; most show commands run as a normal user.
  • Most set commands take store=active (until next reboot) or store=persistent (permanent, the default).
  • Linux does the same with ip and sysctl, macOS with networksetup.
  • In the video only read-only show commands were run on an office PC.

33.2 set global and the starting TTL

defaultcurhoplimit: the starting TTL
  1. 1.Windows PC sends a packet with TTL 128 (default)

  2. 2.First router decrements TTL by 1

  3. 3.Each router in the ISP network decrements it again

  4. 4.TTL still left at the server -> packet delivered

  5. 5.If defaultcurhoplimit=2, TTL hits 0 inside the ISP -> packet dropped

Terminal
netsh int ipv4 show globalnetsh int ipv4 show compartments
Output
$ netsh int ipv4 show globalQuerying active state...General Global ParametersDefault Hop Limit                   : 128 hopsNeighbor Cache Limit                : 256 entries per interfaceRoute Cache Limit                   : 4096 entries per compartmentICMP Redirects                      : enabledSource Routing Behavior             : dontforwardTask Offload                        : enabledMulticast Forwarding                : disabledMinimum Mtu                         : 576$ netsh int ipv4 show compartments    Id  Interfaces  Routes  HopLimit------  ----------  ------  --------     1           8     124       128
  • A compartment is a separate routing world (used e.g. with VPNs); set compartment gives one compartment its own default hop limit.
  • set global has 54 option rows: hop limit, cache limits, ICMP redirects, source routing, task offload, media sense, min MTU and more.
  • Save the output of show global before changing anything, so you can restore the values.
Output
defaultcurhoplimit=64      default TTLneighborcachelimit=256     ARP cache maxroutecachelimit=4096       route cache maxreassemblylimit=N          reassembly buffericmpredirects=disabled     redirect ignoresourceroutingbehavior=drop source routetaskoffload=disabled       NIC offload offdhcpmediasense=enabled     cable sensemldlevel=none|sendonly|all multicast levelmldversion=version3        IGMP versionmulticastforwarding=...    multicast forwardrandomizeidentifiers=...   random IDsminmtu=576                 minimum MTUloopbackexecutionmode=...  loopback modestore=active|persistent    temp | permanent

33.3 set compartment and set dynamicportrange

  • A dynamic (ephemeral) port is the temporary client-side port Windows picks when your browser connects to a server.
  • Default TCP and UDP range: start 49152, 16384 ports.
  • Servers that open thousands of outgoing connections enlarge it with set dynamicportrange.
Terminal
netsh int ipv4 show dynamicportrange tcpnetsh int ipv4 show dynamicportrange udp
Output
$ netsh int ipv4 show dynamicportrange tcpProtocol tcp Dynamic Port Range---------------------------------Start Port      : 49152Number of Ports : 16384$ netsh int ipv4 show dynamicportrange udpProtocol udp Dynamic Port Range---------------------------------Start Port      : 49152Number of Ports : 16384
Output
set compartment 1 128  compartment=1           compartment ID  defaultcurhoplimit=128  its default TTL  store=active            until next reboot  store=persistent        permanentset dynamicportrange tcp 10000 20000  protocol=tcp            TCP ports  protocol=udp            UDP ports  startport=10000         first port  numberofports=20000     how many ports  store=active            until next reboot  store=persistent        permanent (default)

33.4 set interface: forwarding, MTU, metric

forwarding=enabled: a Windows PC as a router
  1. 1.Windows PC has two adapters: one in LAN A, one in LAN B

  2. 2.Laptop in LAN A sends a packet for the server in LAN B

  3. 3.Packet reaches the Windows PC

  4. 4.Forwarding is disabled by default -> packet dropped

  5. 5.Admin sets forwarding=enabled on both interfaces

  6. 6.PC now routes: packet forwarded to the server in LAN B

Terminal
netsh int ipv4 show interfaces 1netsh int ipv4 show subinterfaces 1
Output
$ netsh int ipv4 show interfaces 1Interface Loopback Pseudo-Interface 1 ParametersIfIndex                            : 1State                              : connectedMetric                             : 75Base Reachable Time                : 30000 msDAD Transmits                      : 0Forwarding                         : disabledAdvertising                        : disabledNeighbor Discovery                 : disabledWeak Host Sends                    : disabledECN capability                     : application$ netsh int ipv4 show subinterfaces 1       MTU  MediaSenseState      Bytes In     Bytes Out  Interface4294967295                1             0        110440  Loopback Pseudo-Interface 1
  • Most used: forwarding, mtu and metric (smaller metric = preferred adapter for routes).
  • Others: neighbor discovery timers, DAD, weak host model, Wake on LAN patterns, ECN marking (45 rows in total).
  • Get the interface name or index from show interfaces; subinterface MTU is changed with set subinterface.
Output
interface=12 | "Ethernet" name or indexforwarding=enabled        packets forwardadvertise=enabled         router advertsmtu=1400                  interface MTUmetric=10                 route preferencenud=enabled               neighbor checkbasereachabletime=30000   reachable (ms)retransmittime=1000       retransmit (ms)dadtransmits=0            DAD offrouterdiscovery=dhcp      router discoveryweakhostsend=enabled      weak host sendweakhostreceive=enabled   weak host receiveignoredefaultroutes=...   default route skipforcearpndwolpattern=...  Wake on LANecncapability=ect0        ECN marking

33.5 set dnsservers and set winsservers

  • source=dhcp takes DNS from DHCP; source=static uses your own list; address=none clears it.
  • register= decides dynamic DNS registration (none, primary, both); validate=no skips the server check.
  • set replaces the whole list; for a second server use add dnsservers index=2.
  • set winsservers has the same pattern; WINS is legacy NetBIOS naming.
Output
set dnsservers Ethernet static 8.8.8.8  name="Ethernet"   name or index  source=dhcp       DNS from DHCP  source=static     your own DNS list  address=8.8.8.8   DNS server IP  address=none      clear the list  register=none     dynamic DNS off  register=primary  primary suffix  register=both     primary + connection  validate=yes|no   server checkset winsservers Ethernet static 192.168.1.5  source=dhcp|static  where WINS comes from  address=192.168.1.5 WINS server IP  address=none        clear the list

33.6 Neighbors, routes and subinterface MTU

Terminal
netsh int ipv4 show neighbors 1netsh int ipv4 show route
Output
$ netsh int ipv4 show neighbors 1Interface 1: Loopback Pseudo-Interface 1Internet Address                              Physical Address   Type224.0.0.22                                                       Permanent224.0.0.251                                                      Permanent239.255.255.250                                                  Permanent$ netsh int ipv4 show routePublish  Type      Met  Prefix                    Idx  Gateway/Interface NameNo       System    256  127.0.0.0/8                 1  Loopback Pseudo-Interface 1No       System    256  127.0.0.1/32                1  Loopback Pseudo-Interface 1No       System    256  127.255.255.255/32          1  Loopback Pseudo-Interface 1No       System    256  224.0.0.0/4                 1  Loopback Pseudo-Interface 1No       System    256  255.255.255.255/32          1  Loopback Pseudo-Interface 1
  • set neighbors: static ARP entry (fixed MAC for an IP), helps against ARP spoofing.
  • set route: change nexthop, metric and lifetimes (1d, 12h) of an existing route.
  • set subinterface: changes only the MTU.
Output
set neighbors 12 192.168.1.1 00-11-22-33-44-55  address=IP | neighbor=MAC  static ARPset route 10.2.0.0/16 Ethernet 10.0.0.1  prefix=10.2.0.0/16    which route  nexthop=10.0.0.1      gateway  siteprefixlength=16   site prefix  metric=5              route metric  publish=no|age|yes    advertise in RA  validlifetime=1d      valid for  preferredlifetime=12h preferred forset subinterface Ethernet mtu=1400  subinterface=LUID     if severalstore=active|persistent  all three

33.7 Statistics: show ipstats and show tcpstats

  • ipstats confirms Forwarding Disabled and Default TTL 128; Datagrams Forwarded is 0 because the PC is not a router.
  • tcpstats: fast-growing Retransmitted Segments is a sign of packet loss; Attempts Failed counts failed connects.
  • Add rr=5 to refresh the output every 5 seconds.
Terminal
netsh int ipv4 show ipstatsnetsh int ipv4 show tcpstats
Output
$ netsh int ipv4 show ipstatsMIB-II IP StatisticsForwarding is:                      DisabledDefault TTL:                        128In Receives:                        17086172In Header Errors:                   0Datagrams Forwarded:                0In Discarded:                       15883Out Requests:                       18967740Out No Routes:                      957$ netsh int ipv4 show tcpstatsTCP StatisticsActive Opens:                           70535Passive Opens:                          25942Attempts Failed:                        9462Currently Established:                  32In Segments:                            153175210Out Segments:                           151632353Retransmitted Segments:                 365174

33.8 The show menu (91 rows)

show ...What it displays
addresses | configIP, gateway, DNS
compartmentsCompartments
destinationcacheDestination (path) cache
dnsservers | winsserversDNS, WINS
dynamicportrange / excludedportrangeEphemeral ports / reserved ports
globalGlobal settings
interfaces | subinterfacesPer-adapter parameters, MTU
ipaddresses | joinsIPs, multicast groups
neighbors | ipnettomediaARP cache
route | offloadRoutes, offload
ipstats | icmpstats | tcpstats | udpstatsCounters
tcpconnections | udpconnectionsLive sessions

Modifiers on every show: level=verbose (extra detail), store=persistent (saved settings), rr=5 (auto refresh).

33.9 Common mistakes

  • Thinking set dnsservers adds a server: it replaces the whole list (two servers -> set static 8.8.8.8 -> one left).
  • Leaving test settings as persistent: use store=active for tests, persistent for the final change.
  • Lowering defaultcurhoplimit too far: packets die inside the ISP.
  • Changing set global values without saving show global first.

33.10 Interview tips

  • Is forwarding on and what is the default TTL? -> netsh int ipv4 show ipstats (first lines).
  • Windows as a router: set interface forwarding=enabled on both adapters, make it the gateway (or add routes), confirm Datagrams Forwarded grows.
  • Default ephemeral range: 49152 + 16384 ports; enlarge with set dynamicportrange for port exhaustion.
  • Rising Retransmitted Segments in tcpstats points to packet loss.