Before analyzing the two modes, a core principle must be established: WSL2 (running a full Linux kernel) and Windows (running the NT kernel) are two separate operating systems. The loopback interface (localhost
, lo
) is, by definition, a kernel-level internal affair, with traffic designed to never leave the local OS’s networking stack.
Therefore, WSL2’s ::1
points to the Linux kernel itself, while Windows’ ::1
points to the Windows kernel itself. They are two isolated, non-communicating addresses. When you attempt to connect to ::1
from within WSL2, the request will never leave WSL2 to reach Windows. The connection failure is the expected behavior according to networking fundamentals.
The reason 127.0.0.1
magically works is due to a special cross-OS-boundary forwarding/relay mechanism that Microsoft has implemented for IPv4. How this is implemented differs between networking modes.
1. Default NAT Mode: The Isolated Virtual Network#
In this mode, WSL2 communicates with the host through a virtual switch, and its network environment is relatively independent.
Interface Observation#
WSL2 ip a
Output (NAT Mode):
1# ...
22: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
3 link/ether 00:15:5d:xx:xx:xx # A typical Hyper-V virtual MAC address
4 inet 172.20.x.x/20 # A virtual address in a private IP range
5# ...
Windows ipconfig /all
Output:
1# ...
2Description . . . . . . . . . . . : Realtek PCIe GBE Family Controller
3Physical Address. . . . . . . . . : AA-BB-CC-DD-EE-FF
4IPv4 Address. . . . . . . . . . . : 192.168.1.100
5# ...
Analysis & Conclusion:
- Interface Mismatch: The MAC address (
00:15:5d:...
) and IP address (172.20.x.x
) ofeth0
inside WSL2 are completely different from the Windows physical NIC. This serves as physical proof that WSL2 operates on a virtual network, managed by Hyper-V, that is isolated from the host. - Explanation of
localhost
Behavior:127.0.0.1
(IPv4): Traffic successfully reaches Windows because the WSL2 networking service applies a special Network Address Translation (NAT) rule at the egress point, routing traffic for this destination to the host’s gateway address on the virtual network.::1
(IPv6): This special NAT mechanism is not implemented for IPv6. Therefore, traffic to::1
follows standard routing to WSL2’s ownlo
interface, which is isolated from Windows, resulting in connection failure.
2. Mirrored Mode: The Shared Physical Network & The Special Internal Channel#
This mode is designed to eliminate network isolation, making WSL2 a “peer” to the host on the network.
Interface Observation#
WSL2 ip a
Output (Mirrored Mode):
1# ...
22: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
3 link/ether aa:bb:cc:dd:ee:ff # <-- Identical to Windows Physical MAC
4 inet 192.168.1.100/24 # <-- Identical to Windows IP
5 inet6 fe80::xxxx:xxxx:xxxx:xxxx/64 # <-- Identical to Windows Link-local IPv6
63: loopback0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500
7 link/ether 00:15:5d:yy:yy:yy # <-- A separate, virtual MAC address
8# ...
Analysis & Conclusion:
- The Mirroring of
eth0
: The MAC and IP addresses of WSL2’seth0
are identical to the Windows physical NIC. This proves that WSL2’s external network connection is a direct mirror of the host’s adapter; they share the same network identity. - Explanation of
localhost
Behavior:127.0.0.1
(IPv4): Although the external network is shared, the loopback interfaces (lo
) of the WSL2 (Linux kernel) and Windows (NT kernel) remain isolated from each other. The successful communication relies on a mechanism known as the “localhost relay”.::1
(IPv6): The “localhost relay” mechanism has a known limitation of being IPv4-only. Therefore, traffic to::1
is not relayed and terminates at WSL2’s own isolatedlo
interface.
Discussion of the loopback0
Interface#
The loopback0
interface, which appears in Mirrored mode, is identified by its name and virtual MAC address (00:15:5d:...
) as a special-purpose virtual interface provided by Hyper-V. This shows that even in mirrored mode, some virtualization components remain active.
Its role can be inferred as: A dedicated channel for kernel-level internal communication between Windows and WSL2.
- Vehicle for the
localhost
Relay: The “localhost relay” mechanism described above is very likely implemented over thisloopback0
interface. When WSL2 sends traffic to127.0.0.1
, it is specially routed toloopback0
, which is then received by a corresponding virtual interface on the Windows side and injected into the host’s networking stack. - Other Management Traffic: In addition to the
localhost
relay, this interface may also carry other management and control traffic between WSL2 and Windows, providing a stable, internal communication path that bypasses the external physical network (eth0
).
Summary of Findings#
- The Isolation of
localhost
is Fundamental: Regardless of the networking mode, as two separate kernels, the loopback interfaces (lo
) of WSL2 and Windows are always isolated. The failure of::1
faithfully reflects this underlying truth and is the expected behavior based on networking principles. - The availability of
127.0.0.1
is a Special Exception: Its successful communication is an IPv4-only “convenience feature” implemented by Microsoft through different technologies (NAT in one mode, a relay channel in the other). - Interface Differences are Key Evidence: The
ip a
comparison clearly reveals the architectural difference between the modes: an isolated virtualeth0
in NAT mode versus a shared physicaleth0
in Mirrored mode. loopback0
is a Key Component of Mirrored Mode: Its presence provides an independent, internal communication bridge that enables special host-guest interactions, such as thelocalhost
relay, to function even while the main network is shared.