# Accéder à un port de sa distribution WSL 2 depuis le réseau local

{% hint style="info" %}
WSL 2 dispose de son propre réseau, les distributions sont donc uniquement disponibles depuis la machine hôte par défaut, afin qu'elles le soient également depuis d'autres machines du réseau local il faut configurer un proxy de port.
{% endhint %}

On ouvre Windows PowerShell en mode administrateur.

On récupère l'IP de la distribution à laquelle on souhaite se connecter :

```powershell
wsl -d <NOM DE LA DISTRIBUTION> hostname -I
```

On configure un proxy de port :

```powershell
netsh interface portproxy add v4tov4 listenport=<PORT D'ÉCOUTE> listenaddress=0.0.0.0 connectport=<PORT DE CONNEXION À LA DISTRIBUTION> connectaddress=<IP DE LA DISTRIBUTION>
```

On rajoute dans le firewall utilisé par Windows une règle afin d'ouvrir le trafic entrant sur le port d'écoute choisi.

***

## Commandes utiles

Lister les proxys de ports existants :

```powershell
netsh interface portproxy show all
```

Supprimer un proxy de port :

```powershell
netsh interface portproxy delete v4tov4 listenport=<PORT D'ÉCOUTE> listenaddress=0.0.0.0
```

Supprimer tous les proxys de ports existants :

```powershell
netsh interface portproxy reset
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://knowledge.jonathan-about.com/windows/windows-subsystem-for-linux/acceder-a-un-port-de-sa-distribution-wsl-2-depuis-le-reseau-local.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
