How to prioritise IPv4 over IPv6 on Windows 10 and 11
IPv6 is an integral part of Windows. It's tempting to disable IPv6 on Windows especially on home networks. This can have a variety of side effects that might cause applications and processes to misbehave. Microsoft explicitly does not recommend you disable IPv6. The best way to ensure your Windows computer uses IPv4 is to simply change the IPv6 prefix policy precedence.
There are two ways to do this:
- Create a registry entry to prefer IPv4 over IPv6.
- Directly modify the IPv6 prefix policies to prefer IPv4 over IPv6.
Method 1: Registry Entry
You will need to reboot for the change to take effect.
- Login to your computer as an administrator
- Run the registry editor (regedt32.exe)
- Add a registry key per the screenshot below then reboot for the change to take effect. To undo this change, simply delete the registry entry, then reboot again.
Location: HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters
Key: DisabledComponents
Type: REG_DWORD
Value: 0x20
Method 2: Modify IPv6 Prefix Policies
This is slightly more complicated but you don't need to reboot your computer for the changes to take effect.
- Login to your computer.
- Open an elevated command prompt and type:
netsh interface ipv6 show prefixpolicies
You should see the following output:
Precedence 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 ::/96
The first line with a precedence of 50 is the IPv6 localhost address. The second line with a precedence of 40 is all (global) IPv6 unicast addresses. The third with a precedence of 35 is all IPv4 to IPv6 mapped addresses. A complete list of IPv6 prefixes can be found here.
- To change the precedence you need to reorder the precedence of all prefix policies to ensure the IPv4 to IPv6 mapped addresses has the highest priority. All prefix policies must be entered. The higher the prefix value the more preferred it is. Hence, type or cut and paste the following at the elevated command prompt:
netsh interface ipv6 set prefixpolicy ::ffff:0:0/96 50 0
netsh interface ipv6 set prefixpolicy ::1/128 40 1
netsh interface ipv6 set prefixpolicy ::/0 30 2
netsh interface ipv6 set prefixpolicy 2002::/16 20 3
netsh interface ipv6 set prefixpolicy 2001::/32 5 5
netsh interface ipv6 set prefixpolicy fc00::/7 3 13
netsh interface ipv6 set prefixpolicy fec0::/10 1 11
netsh interface ipv6 set prefixpolicy 3ffe::/16 1 12
netsh interface ipv6 set prefixpolicy ::/96 1 4
- To confirm the changes have taken effect type the following:
netsh interface ipv6 show prefixpolicies
You will now see the precendence list has changed as follows:
Precedence Label Prefix
---------- ----- --------------------------------
50 0 ::ffff:0:0/96
40 1 ::1/128
30 2 ::/0
20 3 2002::/16
5 5 2001::/32
3 13 fc00::/7
1 11 fec0::/10
1 12 3ffe::/16
1 4 ::/96
Now when you ping a host (for example), the IPv4 address (i.e. 127.0.0.1) will be used in preference to the IPv6 address (i.e. ::1). For example:
C:\>ping localhost
Pinging WORKSTATION [127.0.0.1] with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
To undo this change simply reset the precedence as follows:
netsh interface ipv6 reset