microsoft / microsoft/WSL

Forward other 127.0.0.1/8 addresses under mirrored mode

Open
#41,116 0 comments 0 reactions 0 assignees View on GitHub
feature network wsl2
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

**Is your feature request related to a problem? Please describe.**
Under linux, when testing my server software, I have it bind to `127.1.2.3 : 80`, so that it has a unique set of cookies. However, under WSL, only binds to `0.0.0.0` or `127.0.0.1` appear to get forwarded to the host, and the binding to `127.1.2.3` doesn't get forwarded.

**Describe the solution you'd like**
I would like a way to have WSL forward localhost bindings under addresses other than `127.0.0.1` and `0.0.0.0` to the host.

**Describe alternatives you've considered**
- I can bind it instead to `127.0.0.1`, but then it shares its cookies with anything else that is bound on `127.0.0.1`.

- I could also bind it to `0.0.0.0`, but that will prevent doing anything else on port 80. (The firewall does appear to prevent it listening to anything else on the local network, so that isn't a concern).

- I could instead have a domain under windows/system32/drivers/etc/hosts that points to 127.0.0.1 (so that cookies won't be shared), but that would require a set up on each computer, and still won't allow multiple different things listening on port 80 without having to set up a http proxy.

**Additional context**
Test matrix for my tests:

| bind address | curl 127.0.0.1 | curl 127.1.2.3 |
|--------------|:--------------:|:--------------:|
| 0.0.0.0 | Works | Works |
| 127.0.0.1 | Works | - |
| 127.1.2.3 | - | __Fails__ |

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the mirrored-mode test matrix with services bound to 0.0.0.0, 127.0.0.1, and another 127.0.0.0/8 address, then trace the WSL localhost forwarding path. Done means bindings such as 127.1.2.3 are forwarded to the Windows host while preserving the existing behavior for 127.0.0.1 and 0.0.0.0.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux
Domain
networking, operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.