The IPv6 protocol takes precedence over IPv4 in modern versions of Windows. For example, if you ping a remote device on your LAN using the hostname (or the localhost), the IPv6 address will be returned instead of the IPv4 address.
Ping srv01
Pinging srv01.contoso.com [fe80::c09::d4e6::189f::f661%3] with 32 bytes of data
Reply from fe80::c09::d4e6:189f:f661%3: time<1ms
Reply from fe80::c09::d4e6:189f:f661%3: time<1ms
As you can see, the ping command returned an IPv6 address rather than an IPv4 host address. Windows always tries to use the preferred IPv6 protocol when accessing remote devices.
An IPv6 address will also be returned if you ping the localhost tour by name:
ping $env:COMPUTERNAME
Table of Contents
How to Force Ping to Return IPv4 Address
If you still want to see an IPv4 address of a remote device in the result of the ping command, use the command below:
ping hostname -4
Just add a parameter “-4” after your usual ping command:
Ping srv01 -4
Pinging srv01.contoso.com [192.168.10.21] with 32 bytes of data
Reply from 192.168.10.21: bytes=32 time<1ms TTL=128
Reply from 192.168.10.21: bytes=32 time<1ms TTL=128
In this case the ping command returned the usual IPv4 address of the remote host.
Hint. In some situations, you may need to use the IPv6 protocol to test IPv6 connectivity or functionality. In this case, you need to add the “-6” switch to the ping command:
ping srv01 -6
If IPv6 is disabled or not supported by your computer, remote host, or your ISP, an error occurs:
PING: transmit failed. General failure.
Conversely, there may be situations where you specifically want to ping IPv6 address instead of IPv4, such as testing IPv6 connectivity or functionality.
Prefix Policy Precedence on Windows
IPv6 global unicast addresses are preferred over IPv4 addresses (according to RFC 3484) in all versions of Windows starting from Vista. Internet Protocol version 6 (IPv6) is a mandatory part of Windows, and Microsoft doesn’t recommend you to disable IPv6 completely, even if you don’t use IPv6 addressing in your network. This can have many side-effects, causing applications and processes to malfunction. If you disable it, this can have many side-effects, causing applications, processes and Windows components to malfunction.
Instead of disabling IPv6 completely in Windows, you should use the “Prefer IPv4 over IPv6” option in prefix policies.
To view the current prefix policy table on Windows, run the following command:
netsh interface ipv6 show prefixpolicies
Or you can list prefix policy settings with PowerShell:
Get-NetPrefixPolicy
The following prefix policy settings are used by default on Windows 10/11 and Windows Server 2022/2019/2016.
Precedence Label Prefix
———- —– ——————————–
50 0 ::1/128 (IPv6 loopback)
40 1 ::/0 (Native IPv6)
35 4 ::ffff:0:0/96 (IPv4)
30 2 2002::/16 (6to4)
5 5 2001::/32 (Teredo)
3 13 fc00::/7 (Unique-Local addresses, ULAs)
1 11 fec0::/10 (site-local)
1 12 3ffe::/16 (6bone)
1 3 ::/96 (IPv4compat)
The prefix policy table is similar to the routing table. It determines which IP addresses are preferred when trying to connect to a remote host. It determines which IP addresses are preferred when establishing a remote connection. Windows uses this prefix table to determine which address to use, then multiple addresses are available for the hostname (IPv4 and IPv6 in this case).
In this table, the policy “1 ::/0” (Native IPv6) takes precedence over “::ffff:0:0/96” (IPv4). A protocol with a higher Precedence value in this table has a higher priority. By default, the ::ffff:0:0/96 prefix has a lower priority than ::0 meaning that IPv6 is preferred over IPv4 on this Windows host.
How to Prioritize IPv4 over IPv6 on Windows
You can prioritize IPv4 over IPv6 protocol in Windows stack by increasing the prefix precedence. In order to increase the priority of the IPv4 prefix policy and decrease the IPv6 precedence, run the following command in an elevated command prompt:
netsh interface ipv6 set prefix ::/96 60 3
netsh interface ipv6 set prefix ::ffff:0:0/96 55 4
In this case, you don’t need to reboot Windows, and the IPv4 protocol immediately takes a higher priority.
You can run a ping command again and check that the IPv4 address of the remote host is returned. Instead of returning an IPv6 address, the remote server started returning an IPv4 address (192.168.10.21).
Pinging srv01.contoso.com [192.168.10.21] with 32 bytes of data
Reply from 192.168.10.21: bytes=32 time<1ms TTL=128
Reply from 192.168.10.21: bytes=32 time<1ms TTL=128
Now we’ll check that the server is still pinging by its IPv6 address and that we haven’t broken anything:
ping fe80::c09::d4e6:189f:f661%3
Everything works as it should be. This change will persist across reboots.
List the current prefix priority table:
netsh interface ipv6 show prefixpolicies
As you can see, IPv4 is now used by default when sending the network packets.
You can undo this change by reset the precedence as follows:
netsh interface ipv6 reset
In order to make this change permanent, you can modify or create the DisabledComponents registry parameter under HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters with a value 0x20, which will tell Windows to always prefer IPv4 over IPv6.
You can change the registry entry manually using regedit.exe or the command:
reg.exe add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters /v DisabledComponents /t REG_DWORD /d 0x20 /f
This value allows you to prefer an IPv4 protocol over IPv6 by changing entries in the prefix policy table. Reboot your computer for the changes to take effect.
You can use Group Policy Preferences to deploy this registry key to multiple computers in an Active Directory domain using a GPO.
Hint. To return to Windows default behavior (prefer IPv6 over IPv4), run the command:
reg add hklm\system\currentcontrolset\services\tcpip6\parameters /v DisabledComponents /t REG_DWORD /d 0x0
Other possible values for the DisabledComponents parameter:
IPv6 Functionality |
DisabledComponents registry value |
Disable IPv6 protocol |
0xFF |
Prefer IPv4 over IPv6 |
0x20 |
Disable IPv6 on all nontunnel interfaces |
0x10 |
Disable IPv6 on all tunnel interfaces |
0x01 |
Disable IPv6 on all nontunnel interfaces (except the loopback) and on IPv6 tunnel interface |
0x11 |
Default value |
0x00 |
Note that the value of this registry parameter doesn’t affect the IPv6 checkbox in the properties of the network adapter. This is expected behavior.
2 comments
Thank you so much, I keep this article with my toolbox, very helpful, it helped me a lot.
We? As a small non profit company that have 20 staff member in most of our offices , we do not need IPv6.