By default, if a remote host has both IPv4 and IPv6 addresses, the Windows computer will try to connect to it using its IPv6 address. If the DNS server or mDNS protocol (on the local network) returns that the host has AAAA
and A
records, then by default, the connection is made to the IPv6 address contained in the AAAA record. This can be a problem for some network services or legacy apps that don’t support IPv6 (or don’t listen on that network interface). In this case, you can increase the priority of the IPv4 protocol over IPv6 in Windows.
Let’s look at a simple example of a workgroup-based local network (without a DNS server) that uses broadcast queries for name resolution using the built-in Multicast DNS (mDNS
) protocol. Check which records and addresses the mDNS protocol returns for another computer on the same local network.
Resolve-DnsName DESKTOP-ABCD1234
Here, you can see that there are two records ( AAAA and A) for the remote computer, with IPv6 and IPv4 addresses, respectively. Now, check which protocol is used by default to connect to the remote computer. Perform a simple ping
with a remote computer name. The ping command should return the IPv6 address of the computer instead of the IPv4.
Get the current IPv6 prefix policy settings (which determine the priority of use for different types of addresses) by using the command:
netsh interface ipv6 show prefixpolicies
or
Get-NetPrefixPolicy
Windows uses this table to decide which address to use for a connection when both IPv4 and IPv6 addresses are available for a remote host (the higher the Precedence value, the higher the priority of the policy).
Let’s look at the basic precedence entries:
::1/128
– IPv6 loopback interface (highest priority):/0:
— global IPv6 address::ffff:0:0/96
used to map IPv4 to IPv6::/96
– prefix corresponding to IPv4 address
To change the preference order in the prefix policy so that IPv4 addresses have a higher priority, run the command:
netsh interface ipv6 set prefix ::/96 60 3
netsh interface ipv6 set prefix ::ffff:0:0/96 55 4
This configures Windows to prefer the IPv4 protocol over IPv6 without completely disabling IPv6 (no reboot is required). Try to ping the remote host in your LAN once more. Now, the host name resolution will return the IPv4 address.
Confirm the preference of the IPv4 protocol over the IPv6 protocol in a prefix policy table.
netsh interface ipv6 reset
You can also use the registry to prioritize IPv4 over IPv6. Go to the reg key HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters, create a REG_DWORD entry with name DisabledComponents and value 0x20. Restart the computer for the changes to take effect.
You can set this registry entry manually or from cmd:
reg add HKLM\system\currentcontrolset\services\tcpip6\parameters /v DisabledComponents /t REG_DWORD /d 0x20
To restore the original configuration where IPv6 has higher priority than IPv4, run the following command:
reg add hklm\system\currentcontrolset\services\tcpip6\parameters /v DisabledComponents /t REG_DWORD /d 0x0