Answered by:
IPv6 localhost woes.

Question
-
So, my situation is this...
My OS is XP Pro, I'm using Visual Studio 2008.
I'm developing ASP.NET applications, and use the embedded "Cassini" webserver during development to debug/etc.
I'm also developing an application that uses the stuff in System.ServiceModel, to do Peer To Peer networking using PNRP, using such classes as ServiceEndpoint, ServiceContract, NetPeerTcpBinding, DuplexChannelFactory, etc..
My dillemma is that these two modes of development are in direct conflict with each other, due to IPv6, and it's mapping of localhost to ::1.
So, here's the problem (now that you have context):
Before installing IPv6 on XP, I could develop web applications just fine, and the little webserver would load, go to http://localhost and load up the pages.
Now, since I installed IPv6, localhost maps to ::1.... which is an IPv6 endpoint. That means that it never reaches the little webserver waiting on the 127.0.0.1 endpoint. If I manually type in http://127.0.0.1 of course, it will reach it and everything works fine. But localhost doesn't ever get there.. In fact, it goes no where, because nothing is listening on ::1 port 80. There's no way to change the embedded webserver to go to 127.0.0.1 specifically, because it's hardcoded to launch the http://localhost URL (I confirmed this by examining the webserver's code via Reflector).
Most of the people who have faced this problem have resolved it one of two ways... Either they are on Vista, and they can modify thier c:\windows\system32\drivers\etc\hosts file and remove the reference to ::1 localhost, OR they uninstall IPv6 completely. A third option (on Vista) is to modify the registry value DisabledComponents found at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters , and disable some ore all of the functionality of IPv6.
I'm not on Vista. Neither of the Vista fixes are relevant. My hosts file does not have a line like ::1 localhost. My registry does not have the value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\DisabledComponents. I even tried creating the value and setting it to one of the suggested settings, and it had no effect.
I can't uninstall IPv6 because I need it to develop the Peer to Peer stuff that depends on it.
.......
So... What I want to do is find a way to re-route the ::1 endpoint to 127.0.0.1, OR just get Windows XP to look for the IPv4 address before the IPv6 (so it'll find 127.0.0.1 before it finds ::1 when it resolved the hostname "localhost").
I've looked over the IPv6 documentation a lot.. But honestly, networking on that level is not my strong point, and I can't figure out what I should do... Should I be making a 6over4tunnel, v6v4tunnel, isatap, toredo, or some other kind of interface?... Is there some OTHER hosts files the IPv6 pays attention to? because it doesn't seem to need or notice the one at drivers\etc\hosts.
Can anyone help me understand how to configure the network setup on the machine so that calls to "localhost", with IPv6 enabled, end up at the IPv4 address 127.0.0.1 ?
I've tried everything I can think of....
Thanks,
Troy
Friday, June 27, 2008 4:18 AM
Answers
-
The Vista IPv6 configuration appears to work on XP. At least with SP3 it does.
IPv6 is getting hard to avoid. Office 2007 uses IPv6 internally instead of named pipes. So do other programs.
In your case, setting DisabledComponents to 20 might do the trick. Normally, the OS tries IPv6 addresses before IPv4 addresses. This flag reverses the order (there is a table to control the order that various DNS sources are checked, this setting changes the values in that table).
Look at the last section of
http://www.ipv6day.org/action.php?n=En.Configuration-WindowsVista
I copied part of it below:
Disabling IPv6
Unlike Windows XP, IPv6 in Windows Vista cannot be uninstalled. To disable IPv6 on a specific connection, you can go to the Network Connections folder, obtain properties of the connection and clear the check box next to the Internet Protocol version 6 (TCP/IPv6) component in the list. This method disables IPv6 on your LAN interfaces and connections, but does not disable IPv6 on tunnel interfaces or the IPv6 loopback interface.
To selectively disable IPv6 components and configure behaviors for IPv6 in Windows Vista, create and configure the following registry value (DWORD type)
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\tcpip6\Parameters\DisabledComponents
DisabledComponents is set to 0 by default.
The DisabledComponents registry value is a bit mask that controls the following series of flags, starting with the low order bit (Bit 0):
- Bit 0 Set to 1 to disable all IPv6 tunnel interfaces, including ISATAP, 6to4, and Teredo tunnels. Default value is 0
- Bit 1 Set to 1 to disable all 6to4-based interfaces. Default value is 0
- Bit 2 Set to 1 to disable all ISATAP-based interfaces. Default value is 0
- Bit 3 Set to 1 to disable all Teredo-based interfaces. Default value is 0
- Bit 4 Set to 1 to disable IPv6 over all non-tunnel interfaces, including LAN interfaces and *Point-to-Point Protocol (PPP)-based interfaces. Default value is 0
- Bit 5 Set to 1 to modify the default prefix policy table to prefer IPv4 to IPv6 when attempting connections. Default value is 0
To determine the value of DisabledComponents for a specific set of bits, construct a binary number consisting of the bits and their values in their correct position and convert the resulting number to hexadecimal. For example, if you want to disable 6to4 interfaces, disable Teredo interfaces, and prefer IPv4 to IPv6, you would construct the following binary number: 101010. When converted to hexadecimal, the value of DisabledComponents is 0x2A.
Friday, September 19, 2008 3:26 PM
All replies
-
Well, I was able to work around it another way, by setting up the Web Application's start action to be a Start URL, specified as http://127.0.0.1 instead of it's default "Current Page" setting. This also means you need to speficy the port number for the embedded web server.
But this doesn't answer my real question -- How to configure networking so that requests for localhost go to 127.0.0.1 with IPv6 installed on XP?
Thanks,
Troy
Friday, June 27, 2008 10:41 PM -
The Vista IPv6 configuration appears to work on XP. At least with SP3 it does.
IPv6 is getting hard to avoid. Office 2007 uses IPv6 internally instead of named pipes. So do other programs.
In your case, setting DisabledComponents to 20 might do the trick. Normally, the OS tries IPv6 addresses before IPv4 addresses. This flag reverses the order (there is a table to control the order that various DNS sources are checked, this setting changes the values in that table).
Look at the last section of
http://www.ipv6day.org/action.php?n=En.Configuration-WindowsVista
I copied part of it below:
Disabling IPv6
Unlike Windows XP, IPv6 in Windows Vista cannot be uninstalled. To disable IPv6 on a specific connection, you can go to the Network Connections folder, obtain properties of the connection and clear the check box next to the Internet Protocol version 6 (TCP/IPv6) component in the list. This method disables IPv6 on your LAN interfaces and connections, but does not disable IPv6 on tunnel interfaces or the IPv6 loopback interface.
To selectively disable IPv6 components and configure behaviors for IPv6 in Windows Vista, create and configure the following registry value (DWORD type)
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\tcpip6\Parameters\DisabledComponents
DisabledComponents is set to 0 by default.
The DisabledComponents registry value is a bit mask that controls the following series of flags, starting with the low order bit (Bit 0):
- Bit 0 Set to 1 to disable all IPv6 tunnel interfaces, including ISATAP, 6to4, and Teredo tunnels. Default value is 0
- Bit 1 Set to 1 to disable all 6to4-based interfaces. Default value is 0
- Bit 2 Set to 1 to disable all ISATAP-based interfaces. Default value is 0
- Bit 3 Set to 1 to disable all Teredo-based interfaces. Default value is 0
- Bit 4 Set to 1 to disable IPv6 over all non-tunnel interfaces, including LAN interfaces and *Point-to-Point Protocol (PPP)-based interfaces. Default value is 0
- Bit 5 Set to 1 to modify the default prefix policy table to prefer IPv4 to IPv6 when attempting connections. Default value is 0
To determine the value of DisabledComponents for a specific set of bits, construct a binary number consisting of the bits and their values in their correct position and convert the resulting number to hexadecimal. For example, if you want to disable 6to4 interfaces, disable Teredo interfaces, and prefer IPv4 to IPv6, you would construct the following binary number: 101010. When converted to hexadecimal, the value of DisabledComponents is 0x2A.
Friday, September 19, 2008 3:26 PM -
I tried these registry settings.
This does mot help me.
My application is still using ipv6 local loopback adress ::1 to send the result
We are using Apache tomcat web server.
Its a 2k8 64 bit server and I'm looking for work around.
Either making my web server use IPV4 local loopback address
or disabling IPV6 local loopaback address from the interface.
Can any please help??Thursday, June 11, 2009 2:26 PM -
Just go to Windows\System32\Drivers\etc, if hosts file is there, edit it, if it is not, create it with the single line
127.0.0.1 localhost
BTW, on my Windows Vista 64 Ultimate the etc directory did not exist, but when I created it, it happen to have hosts, protocols etc files already, with hosts having the following lines:
127.0.0.1 localhost
::1 localhost
The last line takes priority, so localhost was resolved to ::1 and a some applications just did not work.
MS used to be smarter than break compatibility in this way.
Pavel VerevkinFriday, March 12, 2010 3:16 PM -
Unbelievable. After migrating a server we have spent hours just trying to find why most applications failed to work. Finally we had to remove the line ::1 localhost on the hosts file.
I agree with Panel, MS used to be way smarter to that.
Cheers!
Thursday, January 6, 2011 6:15 PM