16

We tried installing a 3rd party software product on a new Windows Server 2008 R2 machine and found that everything works except for accessing local services through loopback addresses such as localhost or the computer name (ex: VPS-Web which resolves to localhost). We are not using IPv6 and would like to disable it until the software is compatible.

I tried using these instructions for disabling IPv6 on Windows 2008 R2 but it did not disable the protocol for localhost. Pinging localhost or VPS-Web will still return ::1: instead of 127.0.0.1. I can use ping localhost -4 to get the correct address, but IPv6 takes precedence over IPv4 so the 3rd party software only gets the IPv6 address.

Greg Bray
  • 5,610
  • 5
  • 36
  • 53
  • Have you tried contacting the vendor to see if they have a workaround? Ping requests IPv6 address, hence it will get ::1, applications that don't support IPv6 wont get those addresses though. – Chris S Jan 04 '11 at 21:49
  • The software is an abomination of various components (JAVA, Tomcat, Apache, MSSQL, SAP, JDBC, WMI) any one of which could be the problem. I'm not using IPv6, so I'd like to disable it. Also it concerns me that there does not appear to be an option to do this for the loopback adapter. – Greg Bray Jan 05 '11 at 00:22

6 Answers6

13

I had initially checked the host file as SilverbackNet suggested, but on a Windows 2008 R2 server this is the default file:

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

# indicates a comment in the host file, so all the entries are commented out, and the first line is a bit confusing. I then noticed that there were two entries for localhost that were commented out, so I tried uncommenting the IPv4 one and it worked! I should have tried that first but I was thrown off track by the first line. Using the below host file pinging the computer name or localhost will always return an IPv4 address, which fixes the problem with the 3rd party software!

# localhost name resolution is handled within DNS itself.
#   ::1         localhost
127.0.0.1       localhost
127.0.0.1       VPS-Web
Greg Bray
  • 5,610
  • 5
  • 36
  • 53
  • Did this remove the ipv6([::]) listening in netstat? – Jared Burrows Mar 24 '13 at 01:52
  • It does not. [::] is the IPv6 equivalent of 0.0.0.0, which represents all available IP addresses on the system. The above fix is specifically for the localhost loopback address. I have both the above settings as well as the DisabledComponents=0xffffffff registry key and I still see applications listening on [::]. I don't know if there is any way to fully disable IPv6. – Greg Bray Mar 25 '13 at 16:14
  • Thanks for confirming my problem! I was just making sure :) – Jared Burrows Mar 26 '13 at 22:20
  • 1
    This didn't work for me. I flushed dns cache and rebooted, but it still returns an IPv6 address... – Redoman Dec 13 '19 at 11:46
5

Setting "DisabledComponents" = 0x20 under

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\

will set that machine to use IPv4 instead of IPv6 in prefix policies.

Create the registry key if it doesn't exist.

SomeGuy
  • 51
  • 1
  • 1
2

Have you tried removing the entry from the hosts file in %systemroot%\system32\drivers\etc? That should do it, if you just need "localhost" to always be IPv4. However, if it's based on the server name, this probably won't work.

SilverbackNet
  • 383
  • 2
  • 10
  • 1
    The hosts file on windows is under %systemroot%\system32\drivers\etc and even if it doesn't contain an ipv6 reference for localhost pinging localhost will get a ::1 response. – Helvick Jan 04 '11 at 22:00
  • You will get a 127.0.0.1 response, if you map localhost to that (and ONLY to that, not to IPv6) – Frank N Jan 28 '13 at 16:41
2

The initial ServerFault thread about using the DisabledComponents registry value is really the best way to do this. Hosts file tweaking should never be necessary in a well functioning network. The registry tweak is also much easier to deploy and revert via group policy if you have an Active Directory.

The reason it didn't work is because that DisabledComponents registry setting is read as a set of bit flags and not simply on or off. Here is the official documentation from Microsoft on the subject:
How to disable IP version 6 (IPv6) or its specific components in Windows 7, in Windows Vista, in Windows Server 2008 R2, and in Windows Server 2008

The short version is that to completely disable IPv6 on Vista/2008 and beyond, set the value of DisabledComponents to 0xff. I do this on every machine I manage where we're not explicitly using IPv6. It has the nice side effect of significantly shortening the output of the ipconfig command.

Ryan Bolger
  • 16,755
  • 4
  • 42
  • 64
  • 2
    According to your link (http://support.microsoft.com/kb/929852#letmefixit) this registry entry allows to disable IPv6 in many places EXCEPT loopback... – Frank N Jan 28 '13 at 16:47
  • 1
    You are correct. However, there are values that change the default network functionality to prefer IPv4 over IPv6 which will effectively solve the OP's problems with connecting to localhost or the NetBIOS computer name. – Ryan Bolger Jan 28 '13 at 19:00
  • None of these have actually worked for me in Windows Server 2012R2. This includes trying hosts modification, DisabledComponents registry setting in addition to many other ideas I've seen elsewhere. Works on Windows Server 2008 but I have no solution for 2012R2. – Scott White Jun 23 '15 at 15:09
  • You need to reboot after modifying the DisabledComponents value. If you've set it to 0xffffffff, there is no way it didn't work even on 2012R2. The results of running an ipconfig should return nothing that is IPv6 related and as such, pinging localhost should ping the v4 address. – Ryan Bolger Jun 23 '15 at 17:02
  • New finding shows that the correct value should be 0xFF instead of 0xFFFFFFF to avoid a 5-second boot delay. See the updated Microsoft KB929852 (This still does not disable the loopback though) – wandersick Aug 02 '16 at 00:58
  • +1, because this is as close as you'll get to a "right" way to do it - though there is no right way. The warning from Microsoft you see about disabling IPv6 on their site is not nearly strong enough. IPv6 disabled is an _untested and unsupported_ configuration, and if you do have to contact MS for support with anything related to this, they might refuse to help you until you turn it back on. But it's perfectly OK to disable IPv4. That _is_ a tested, supported configuration. – Michael Hampton Aug 06 '16 at 03:51
0

You can also go into the properties of the NIC itself, and uncheck the IPv6 box, leaving IPv4 enabled. Should do the trick.

JohnThePro
  • 2,595
  • 14
  • 23
-3

Try adding a line to your hosts file like:

::1 VPW-Web

This should enable the resolver to get VPW-Web as a name for IPv6 loopback.

BillThor
  • 27,737
  • 3
  • 37
  • 69