netsh interface (3/5)
netsh interface ipv6 is the command-line context for the Windows IPv6 stack: addresses, DNS, routes, neighbors, prefix policies, port ranges and IPv6-over-IPv4 tunnels (6to4, ISATAP, v6v4tunnel). Part 3 covers the context, 6to4/isatap, add, delete and the first set commands, with real Linux equivalents.
34.1 What it does and where it runs
- Windows only; on Linux the same jobs are done by ip -6 and sysctl.
- show runs as a normal user; add, set and delete need an admin Command Prompt.
- Changes are persistent by default; store=active keeps them only until the next reboot.
- dump prints the whole IPv6 config as a script; reset removes all manual IPv6 settings (restart needed).
- Sub-contexts: 6to4 and isatap.
netsh interface ipv6 ?$ netsh interface ipv6 ?Commands in this context:6to4 - Changes to the `netsh interface ipv6 6to4' context.add - Adds a configuration entry to a table.delete - Deletes a configuration entry from a table.dump - Displays a configuration script.isatap - Changes to the `netsh interface ipv6 isatap' context.reset - Reset the IP configurations.set - Sets configuration information.show - Displays information. The following sub-contexts are available: 6to4 isatap34.2 6to4 and ISATAP: how they work
- Step 1
1.Laptop has IPv6; the server is IPv6-only; the ISP gives only IPv4
- Step 2
2.Laptop sends an IPv6 packet to the home router
- Step 3
3.Router wraps it in an IPv4 packet with protocol number 41
- Step 4
4.Wrapped packet crosses the IPv4 internet to a 6to4 relay
- Step 5
5.Relay strips the outer IPv4 header and forwards the IPv6 packet to the server
ISATAP does the same job inside a company network
- Both technologies are deprecated; default means built-in behaviour, practically disabled on today's builds.
- Every set option takes enabled, disabled, automatic or default.
- 6to4: set interface (act as router), set relay (name + interval in minutes), set routing, set state (whole service on/off).
- isatap: set router (company ISATAP router name), set state.
netsh interface ipv6 6to4 show statenetsh interface ipv6 6to4 show relaynetsh interface ipv6 isatap show statenetsh interface ipv6 isatap show router$ netsh interface ipv6 6to4 show state6to4 Service State : defaultUndo on Service Stop : default$ netsh interface ipv6 6to4 show relayRelay Name : defaultUse Relay : defaultResolution Interval : default$ netsh interface ipv6 isatap show stateISATAP State : default$ netsh interface ipv6 isatap show routerRouter Name : defaultUse Relay : defaultResolution Interval : defaultvalues: enabled disabled automatic default6to4 set interface "Private" \ routing=enabled acts as router6to4 set relay name=6to4.ipv6.org. \ state=enabled interval=1440 relay6to4 set routing routing=automatic \ sitelocals=enabled6to4 set state state=disabled \ undoonstop=default service off6to4 show interface|relay|routing|stateisatap set router \ name=isatap.example.com interval=1440isatap set state state=disabledisatap show router|state34.3 add address, dnsservers, neighbors, excludedportrange, potentialrouter
- add address: interface + IPv6 address; no prefix length means /64. type=anycast lets the same address live on several servers.
- After validlifetime/preferredlifetime the address becomes deprecated, then is removed. skipassource=true: never used as a source.
- add dnsservers adds an IPv6 DNS server; index= sets its position.
- add excludedportrange reserves ports (e.g. 20 from 50000) so Windows never gives them to outgoing connections.
- add neighbors: static IPv6-to-MAC entry, like a static ARP entry in IPv4. add potentialrouter adds to an interface's potential router list.
add address "Ethernet" 2001:db8::10/64 interface= address= (/64 default) type=unicast|anycast validlifetime=1d preferredlifetime=12h store=active|persistent skipassource=true not a sourceadd address "Ethernet" fe80::2add dnsservers "Ethernet" \ 2001:4860:4860::8888 end of list name= address=add dnsservers "Ethernet" \ 2001:4860:4860::8844 index=2 validate=yes|no check or skip add excludedportrange protocol=tcp \ startport=50000 numberofports=20 protocol=udp store=active|persistentadd neighbors "Ethernet" fe80::1 \ 12-34-56-78-9a-bc static entry interface= address= neighbor= subinterface=<LUID> store=active|persistentadd potentialrouter "Ethernet" fe80::1 interface= address=34.4 add route and add prefixpolicy
- add route: prefix, interface, nexthop. ::/0 is the default route.
- Smaller metric = preferred route; publish= decides whether the route is advertised in Router Advertisements.
- add prefixpolicy edits the RFC 6724 table that decides whether IPv6 or IPv4 is tried first. Higher precedence = more preferred.
- Current table: ::1 at 50, ::/0 (IPv6) at 40, ::ffff:0:0/96 (IPv4) at 35, so Windows tries IPv6 first. Label matches source with destination.
add route ::/0 "Ethernet" fe80::1 default prefix= interface= nexthop=add route 2001:db8::/48 "Ethernet" \ fe80::1 metric=50 siteprefixlength=48 publish=no|age|yes advertise in RA validlifetime=1d preferredlifetime=12h store=active|persistentadd prefixpolicy ::ffff:0:0/96 \ precedence=35 label=4 prefix= store=active|persistentnetsh interface ipv6 show prefixpolicies$ netsh interface ipv6 show prefixpoliciesPrecedence Label Prefix---------- ----- -------------------------------- 50 0 ::1/128 40 1 ::/0 35 4 ::ffff:0:0/96 30 2 2002::/16 5 5 2001::/32 3 13 fc00::/7 1 11 fec0::/10 1 12 3ffe::/16 1 3 ::/9634.5 add v6v4tunnel (sit tunnel on Linux)
- Step 1
1.add v6v4tunnel: interface name + local IPv4 + remote IPv4
- Step 2
2.pc 192.168.54.10 pings fd00:6464::2 over tun6
- Step 3
3.IPv6 echo request is wrapped in IPv4 (proto 41) -> switch
- Step 4
4.srv 192.168.54.20 strips the outer header, reads the IPv6 packet
- Step 5
5.Echo reply comes back wrapped the same way
ip tunnel add tun6 mode sit \ local 192.168.54.10 remote 192.168.54.20ip -6 addr add fd00:6464::1/64 dev tun6ip link set tun6 upping -c 2 fd00:6464::2# on srv:tcpdump -ni eth0 -c 2 ip proto 41$ ping -c 2 fd00:6464::2PING fd00:6464::2 (fd00:6464::2) 56 data bytes64 bytes from fd00:6464::2: icmp_seq=1 ttl=64 time=0.398 ms64 bytes from fd00:6464::2: icmp_seq=2 ttl=64 time=0.151 ms2 packets transmitted, 2 received, 0% packet loss, time 1026mssrv$ tcpdump -ni eth0 -c 2 ip proto 4117:19:43.825656 IP 192.168.54.10 > 192.168.54.20: IP6 fd00:6464::1 > fd00:6464::2: ICMP6, echo request, id 1807, seq 1, length 6417:19:43.825734 IP 192.168.54.20 > 192.168.54.10: IP6 fd00:6464::2 > fd00:6464::1: ICMP6, echo reply, id 1807, seq 1, length 642 packets captured34.6 delete ... (42 options)
- Every add has a matching delete taking the same values.
- delete excludedportrange needs the exact start port and count used in add.
- destinationcache and neighbors without an interface flush all interfaces.
- delete interface removes only manually created interfaces such as tunnels.
delete address "Ethernet" 2001:db8::10delete dnsservers "Ethernet" all|<IPv6> validate=yes|nodelete potentialrouter "Ethernet" fe80::1delete prefixpolicy ::/96delete route 3ffe::/16 "Ethernet" fe80::1delete excludedportrange tcp 50000 20 (exact match with add)delete destinationcache ["Ethernet"]delete neighbors ["Ethernet"] [fe80::1] subinterface=<LUID>delete interface "Tunnel1" manual onlycommon: store=active|persistent34.7 set address, compartment, dnsservers, dynamicportrange
- set address changes type and lifetimes of an existing address (time format 1d2h3m4s).
- set compartment changes the default hop limit of outgoing IPv6 packets (the IPv6 TTL); current value 128.
- set dnsservers source=dhcp (DHCPv6) or static; address=none clears; register= controls DNS name registration.
- set dynamicportrange: outgoing source port range; current 49152 + 16384 ports.
set address "Ethernet" 2001:db8::10 \ type=unicast|anycast validlifetime=7d preferredlifetime=1d (time: 1d2h3m4s) interface= address= store=active|persistentset compartment compartment=1 \ defaultcurhoplimit=128 store=active|persistentset dnsservers "Ethernet" source=dhcpset dnsservers "Ethernet" static \ 2001:4860:4860::8888 primary address=none clear list register=none|primary|both validate=yes|noset dynamicportrange protocol=tcp \ startport=49152 numberofports=16384 protocol=udp store=active|persistent$ netsh interface ipv6 show compartments Id Interfaces Routes HopLimit------ ---------- ------ -------- 1 8 13 128$ netsh interface ipv6 show dynamicportrange tcpProtocol tcp Dynamic Port Range---------------------------------Start Port : 49152Number of Ports : 1638434.8 Practical on Linux: netsh vs ip -6
| netsh interface ipv6 | Linux equivalent |
|---|---|
| add address ... validlifetime preferredlifetime | ip -6 addr add ... valid_lft preferred_lft |
| add route ... metric=50 | ip -6 route add ... via ... metric 50 |
| add neighbors (static) | ip -6 neigh add ... lladdr (PERMANENT) |
| add v6v4tunnel | ip tunnel add ... mode sit |
| set address preferredlifetime=0 | ip -6 addr change ... preferred_lft 0 (deprecated) |
| set compartment defaultcurhoplimit | sysctl net.ipv6.conf.all.hop_limit |
| set dynamicportrange / add excludedportrange | sysctl ip_local_port_range / ip_local_reserved_ports |
ip -6 addr add 2001:db8:54::10/64 \ dev eth0 valid_lft 86400 \ preferred_lft 43200ip -6 addr show eth0 scope globalip -6 route add 2001:db8:99::/48 \ via fd00:54::3 metric 50ip -6 route show 2001:db8:99::/48ip -6 neigh add fd00:54::99 \ lladdr 02:00:00:00:00:99 dev eth0ip -6 neigh show fd00:54::99$ ip -6 addr show eth0 scope global inet6 2001:db8:54::10/64 scope global tentative dynamic valid_lft 86399sec preferred_lft 43199sec inet6 fd00:54::2/64 scope global nodad$ ip -6 route show 2001:db8:99::/482001:db8:99::/48 via fd00:54::3 dev eth0 metric 50 pref medium$ ip -6 neigh show fd00:54::99fd00:54::99 dev eth0 lladdr 02:00:00:00:00:99 PERMANENTip -6 addr change 2001:db8:54::10/64 \ dev eth0 preferred_lft 0ip -6 addr show eth0 scope globalsysctl -w net.ipv6.conf.all.hop_limit=128sysctl -w \ net.ipv4.ip_local_port_range="49152 65535"sysctl -w \ net.ipv4.ip_local_reserved_ports=50000-50019ip -6 route del 2001:db8:99::/48ip -6 neigh del fd00:54::99 dev eth0ip -6 addr del 2001:db8:54::10/64 dev eth0ip tunnel del tun6ip -6 addr show scope global$ ip -6 addr show eth0 scope global inet6 2001:db8:54::10/64 scope global deprecated valid_lft forever preferred_lft 0sec$ sysctl -w net.ipv6.conf.all.hop_limit=128net.ipv6.conf.all.hop_limit = 128$ sysctl -w net.ipv4.ip_local_port_range="49152 65535"net.ipv4.ip_local_port_range = 49152 65535$ sysctl -w net.ipv4.ip_local_reserved_ports=50000-50019net.ipv4.ip_local_reserved_ports = 50000-50019$ ip -6 addr show scope global inet6 fd00:54::2/64 scope global nodad valid_lft forever preferred_lft forever34.9 Common mistakes
- Thinking a tunnel means encryption: v6v4tunnel and 6to4 only wrap (protocol 41); tcpdump showed inner IPv6 in plain text. Add IPsec or a VPN for security.
- Adding a route with store=active and expecting it after reboot.
- Deleting an excludedportrange with a different start or count.
- Expecting delete interface to remove a physical adapter: it only removes manual (tunnel) interfaces.
34.10 Interview tips
- Static IPv6 on Windows: name from netsh int ipv6 show interfaces, add address "Ethernet" 2001:db8::10/64, add route ::/0 "Ethernet" fe80::1, set dnsservers static, verify with show addresses / show route.
- 6to4/ISATAP/v6v4tunnel carry IPv6 inside IPv4 with protocol number 41; all deprecated.
- Prefix policy (RFC 6724) explains why IPv6 is tried before IPv4.
- store=active is gone after reboot; persistent is the default.