Register
CLIENT AREA
We care about the Environment

Prioritize IPv4 over IPv6 on a Windows server

With the new Evoxt implementation, where all new VM deployments will be assigned an IPv6 address, we have received reports from customers due to websites and servers not supporting IPv6 and causing problems.

All Windows servers will prefer IPv6 over IPv4 if IPv6 is enabled. Disabling IPv6, which is the new internet protocol, will cause your server to be not future-proof. So this guide will help you configure your Windows server network connection to prefer IPv4 over IPv6.

Change IPv4 priority on Microsoft's Network Shell

To do that, you will need to do so from CMD

1) Head to CMD, Windows Search > CMD. Alternatively, you can access it through WIN + R, then type in cmd.exe and press ok.

2) On CMD, copy these lines and paste them into CMD. This will move the priority of the IPv4 mapped address to the top, making Windows use IPv4 as the default internet protocol. ::ffff:0:0/96 is an IPv4 mapped address range, equivalent to IPv4. Created to aid in IPv4 to IPv6 transition.

netsh interface ipv6 set prefixpolicy ::ffff:0:0/96 50 4
netsh interface ipv6 set prefixpolicy ::1/128 40 0
netsh interface ipv6 set prefixpolicy ::/0 30 1
netsh interface ipv6 set prefixpolicy 2002::/16 20 2
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 3




Now try to ping google again. Ping should default to IPv4.



Bonus:
To change IPv6 back to the default internet protocol used, use the command below and do a restart.
netsh interface ipv6 reset




Change IPv4 preference through Registry

1) Head to Registry, Windows Search > Regedit. Alternatively, you can access it through WIN + R, then type in regedit.exe and press ok.

2) Go to HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > Services > Tcpip6 > Parameters (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\)


3) On the folder, right-click and create a Dword (32-bit).

4) Then, rename the entry to DisabledComponents

5) Right-click on the entry and click on modify

6) Enter 0x20 in the value data field as shown in the screenshots below, then click Ok


7) Once this is done, do a server restart.

Now try to ping google again. Ping should default to IPv4.


Bonus:
To change IPv6 back to the default internet protocol used, delete the entry (DisabledComponents) and do a server restart.

Source: https://docs.microsoft.com/en-us/troubleshoot/windows-server/networking/configure-ipv6-in-windows



If these are too complicated, you can also choose to just disable IPv6 networking entirely. However, this will disable the dual stack status and cause your server to be not future-proof. Take a look at this guide here