On Windows, when you ping a remote computer on your LAN by its hostname or a localhost, the command returns an IPv6 device address instead of an IPv4 address. Windows always tries to use the preferred IPv6 protocol when accessing remote devices. Ping reply with IPv6 address, not IPv4, since the IPv6 protocol takes precedence over IPv4.
ping DESKTOP-V79DK27
Pinging DESKTOP-V79DK27.local [fe80::cd84:26d9:6b40:339b%13] with 32 bytes of data:
Ping reply with IPv6 address, not IPv4.
Table of Contents
How to Force Ping to Return IPv4 Address on Windows
If you need to see the IPv4 address of a remote device, you can force the ping command to use a specific protocol. Simply add a “-4” after your usual ping command to use the IPv4 protocol version:
ping DESKTOP-V79DK27 -4
Pinging DESKTOP-V79DK27.localdomain [192.168.31.83] with 32 bytes of data:
Reply from 192.168.31.83: bytes=32 time<1ms TTL=128
Prefix Policy Precedence on Windows
Prefix police precedence is used to set the priorities for using the version of the IP protocols in Windows.
Run the following command to view the current prefix policy table in Windows:
netsh interface ipv6 show prefixpolicies
To view the current prefix policy table on Windows, run the following command:
netsh interface ipv6 show prefixpolicies
Or you can use PowerShell to list prefix policy settings:
Get-NetPrefixPolicy
The following prefix policy settings are used by default on Windows 10/11 and Windows Server 2022/2019/2016.
Precedence | Label | Prefix | Description |
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 |
If both IPv4 and IPv6 addresses are available for the remote hostname, Windows uses this prefix table to determine which address to use for the connection. A protocol with a higher Precedence value in this table has a higher priority. By default the policy “1 ::/0” (Native IPv6) takes precedence over “::ffff:0:0/96” (IPv4). In this case, Windows will use the IPv6 address to make the connection.
Of course, you can also choose to completely disable IPv6 in Windows, so that only IPv4 addresses are used for connections. However, Microsoft explicitly doesn’t recommend to completely disable IPv6 in Windows, even if you don’t use IPv6 addressing in your network. This can have many side-effects, causing applications and processes to malfunction.
Instead, you should enable the “Prefer IPv4 over IPv6” option in prefix policies.
How to Prioritize IPv4 over IPv6 on Windows
You can prioritize IPv4 over IPv6 protocol in Windows stack by increasing the prefix precedence. Open an elevated command prompt and run the command:
netsh interface ipv6 set prefix ::/96 60 3 netsh interface ipv6 set prefix ::ffff:0:0/96 55 4
Check new IP protocol priority settings (the IPv4 protocol is now at a higher level in the stack):
netsh interface ipv6 show prefixpolicies
The IPv4 protocol priority is increased immediately. There is no need to restart Windows. This change will persist across reboots. You can run a ping command again and check that the IPv4 address of the remote host is returned instead of an IPv6 address:
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
Check that the remote host can be reached at its IPv6 address and that you haven’t broken anything:
ping fe80::c09::d4e6:189f:f661%3
To undo the changes and reset the network policy precedence settings to default, use the command:
netsh interface ipv6 reset
You can also use the registry to configure Windows to always prefer IPv4 over IPv6. Modify or create the DisabledComponents registry parameter under HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters with a value 0x20:
reg.exe add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters /v DisabledComponents /t REG_DWORD /d 0x20 /f
You can use Group Policy to deploy this registry key to multiple computers that have joined the Active Directory domain.
Hint. To revert to the Windows default behavior (prefer IPv6 over IPv4), change the DisabledComponents value to 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.
3 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.
Super! this is what i was searching for…