Prefer IPv4 over IPv6 in Windows Networks
By default Windows will prefer IPv6 over IPv4. Below you will see how you can change this behavior to prefer IPv4 over IPv6 in Windows.
Default Address Selection for Internet Protocol version 6 (IPv6)
In dual stack implementations, the destination address selection algorithm can consider both IPv4 and IPv6 addresses – depending on the available source addresses, the algorithm might prefer IPv6 addresses over IPv4 addresses, or vice-versa.
Windows Vista, Windows Server 2008, and later versions of Windows implement RFC 3484 and use a prefix table to determine which address to use when multiple addresses are available for a Domain Name System (DNS) name.
By default, Windows favors IPv6 global unicast addresses over IPv4 addresses.
It is common for IT administrators to disable IPv6 to troubleshoot networking-related issues such as name resolution issues.
Internet Protocol version 6 (IPv6) is a mandatory part of Windows Vista and Windows Server 2008 and newer versions. We do not recommend that you disable IPv6 or its components. If you do, some Windows components may not function.
We recommend using Prefer IPv4 over IPv6 in prefix policies instead of disabling IPV6.
The IPv6 functionality can be configured by modifying the following registry key:
Add the following DWORD to prefer IPv4 over IPv6:
Min Value: 0x00 (default value)
Max Value: 0xFF (IPv6 disabled)
Prefer IPv4 over IPv6
You must restart your computer for these changes to take effect.
|IPv6 Functionality||Registry value and comments|
|Prefer IPv4 over IPv6||Decimal 32|
Binary xx1x xxxx
Recommended instead of disabling IPv6.
|Disable IPv6||Decimal 255|
Binary 1111 1111
See startup delay occurs after you disable IPv6 in Windows if you encounter startup delay after disabling IPv6 in Windows 7 SP1 or Windows Server 2008 R2 SP1.
Additionally, system startup will be delayed for five seconds if IPv6 is disabled by incorrectly, setting the DisabledComponents registry setting to a value of 0xffffffff. The correct value should be 0xff. For more information, see Internet Protocol Version 6 (IPv6) Overview.
The DisabledComponents registry value doesn’t affect the state of the check box. Even if the DisabledComponents registry key is set to disable IPv6, the check box in the Networking tab for each interface can be checked. This is an expected behavior.
You cannot completely disable IPv6 as IPv6 is used internally on the system for many TCPIP tasks. For example, you will still be able to run ping
|Disable IPv6 on all nontunnel interfaces||Decimal 16|
Binary xxx1 xxxx
|Disable IPv6 on all tunnel interfaces||Decimal 1|
Binary xxxx xxx1
|Disable IPv6 on all nontunnel interfaces (except the loopback) and on IPv6 tunnel interface||Decimal 17|
Binary xxx1 xxx1
|Prefer IPv6 over IPv4||Binary xx0x xxxx|
|Re-enable IPv6 on all nontunnel interfaces||Binary xxx0 xxxx|
|Re-enable IPv6 on all tunnel interfaces||Binary xxx xxx0|
|Re-enable IPv6 on nontunnel interfaces and on IPv6 tunnel interfaces||Binary xxx0 xxx0|
You can also roll out these settings in your network by using a group policy.
Alternatively you can change the IPv6 prefix policies precedence to prefer IPv4 over IPv6. The command will modify the source and destination address selection policy for a specified prefix.
The changes will affect immediately without reboot!
Show the actual prefix policy
netsh interface ipv6 show prefixpolicies
Changing precedence for mapped IPv4 addresses
netsh interface ipv6 set prefixpolicy ::ffff:0:0/96 precedence=46 label=4 store=persistent
active: Change only lasts until next boot.
persistent: Change is persistent (default).
Adding a prefix policy
netsh interface ipv6 add prefixpolicy ::/0 precedence=40 label=4 store=active
Deleting a prefix policy
netsh interface ipv6 delete prefixpolicy ::/0
You can reset the IPv6 setting by using the following command and reboot your computer afterwards.
netsh interface ipv6 reset
- Precedence 50 –> IPv6 loopback adapter
- Precedence 40 –> Arbitrary IPv6 Address
- Precedence 35 –> IPv4-mapped IPv6 addresses
- Precedence 30 –> 6to4 tunnel addresses
- Precedence 5 –> Teredo addresses
- Precedence 1 –> IPv4 Addresses
Policy table for IPv6 default address selection
In the table, IPv4 addresses are represented as IPv4-mapped IPv6 addresses.
IPv4-mapped IPv6 addresses
Before changing the precedence from the IPv4 mapped addresses, by default IPv6 is used for internet traffic, because the prefix for the arbitrary IPv6 addresses (::/0) is higher as shown below.
Now I will change the precedence for the IPv4 mapped addresses (::ffff:0:0/96) to be higher than the arbitrary IPv6 addresses (::/0) .
netsh interface ipv6 set prefixpolicy ::ffff:0:0/96 46 4
After changing the precedence for IPv4 mapped addresses (::ffff:0:0/96) to be higher as the arbitrary IPv6 addresses (::/0), Windows will use IPv4 to connect to remote IP addresses.
Unfortunately as you can see in the screenshot above, the nslookup command will still query the IPv6 DNS server instead the IPv4.
The DNS server is dual stacked, meaning that it has both IPv4 and IPv6 addresses. When performing the lookup by specifying the default DNS server as a command line option, nslookup properly loops through the IP addresses starting with IPv6 and ending on IPv4. However when using nslookup interactively, nslookup only tries the first address which is returned by the resolver, which will always be the IPv6 address.
The fix for this is to specify the DNS servers by IP address when using nslookup interactively or use nslookup non-interactively by specifying the default DNS server on the command line.
Here you can see that Windows from now on is using IPv4.
Guidance for configuring IPv6 in Windows for advanced users
Policy table for IPv6 default address selection
Netsh commands for Interface IPv6
Configuring IPv6 in Windows with NetShell