Skip to content

Commit

Permalink
Main > Live (#1986)
Browse files Browse the repository at this point in the history
* Update wsl-config.md (#1949)

* Add kernel requirement for connect-usb.md (#1950)

* Update networking.md (#1962)

Adding the OS requirements for networking features to make it clear when the features are available.

* Doc updates for dnsTunneling and autoProxy (#1970)

* dns and proxy doc updates

* add dnsTunnelingIpAddress setting

* mention generateHosts option

* move bullet point

* rephrase docker desktop point

---------

Co-authored-by: Catalin-Emil Fetoiu <cfetoiu@microsoft.com>

* Fix docker run command (#1956)

Current one will get error "/usr/bin/ls: /usr/bin/ls: cannot execute binary file"

* Updated production faq (#1954)

* Update wsl-config.md (#1959)

Matching the formatting of * near the Key column instead of the value column established lower in the table.

* Update about.md to fix small typo (#1983)

Closes #1973

* Update install-manual.md (#1981)

* Update filesystems.md to clarify Linux path (#1984)

* Update faq.yml to include note about setting username for moving distros (#1982)

* Update faq.yml to include note about setting username for moving distros

* Add set your default user account to faq

---------

Co-authored-by: Matt Wojciakowski <mattwoj@microsoft.com>

* Update wsl-config.md (#1951)

* Update wsl-config.md

Add a description for defaultVhdSize option.

* Minor rewording

* Add note about max related to issue

---------

Co-authored-by: Matt Wojciakowski <mattwoj@microsoft.com>

* Update use-custom-distro.md (#1985)

Fixes #1640

* Extensively clarify "Identify IP address" section. (#1978)

* Extensively clarify "Identify IP address" section.

* Move IP address scenario explanation to Networking doc

* Simplify commands and link to Networking page

* Fix warning typo

---------

Co-authored-by: Matt Wojciakowski <mattwoj@microsoft.com>

---------

Co-authored-by: Craig Loewen <crloewen@microsoft.com>
Co-authored-by: Keith Horton <khorton@microsoft.com>
Co-authored-by: Cătălin Emil Fetoiu <fetoiucatalinemil@gmail.com>
Co-authored-by: Catalin-Emil Fetoiu <cfetoiu@microsoft.com>
Co-authored-by: FantasqueX <fantasquex@gmail.com>
Co-authored-by: Joshua Cooper <Cooperjoshua@gmail.com>
Co-authored-by: Ben Hillis <benhill@microsoft.com>
Co-authored-by: Jimm Chen <38829153+chjfth@users.noreply.github.com>
  • Loading branch information
9 people committed Jul 16, 2024
1 parent ec88118 commit 2973cc4
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 29 deletions.
2 changes: 1 addition & 1 deletion WSL/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ms.topic: article

Windows Subsystem for Linux (WSL) is a feature of Windows that allows you to run a Linux environment on your Windows machine, without the need for a separate virtual machine or dual booting. WSL is designed to provide a seamless and productive experience for developers who want to use both Windows and Linux at the same time.

- Use WSL to install and run various Linux distributions, such as Ubuntu, Debian, Kali, and more. [Install Linux distributions](./install.md) and receive automatic updates from the [Microsoft Store](./compare-versions.md#wsl-in-the-microsoft-store), [import Linux distributions not available in the Microsoft Store](./use-custom-distro.md), or [build your own customer Linux distribution](./build-custom-distro.md).
- Use WSL to install and run various Linux distributions, such as Ubuntu, Debian, Kali, and more. [Install Linux distributions](./install.md) and receive automatic updates from the [Microsoft Store](./compare-versions.md#wsl-in-the-microsoft-store), [import Linux distributions not available in the Microsoft Store](./use-custom-distro.md), or [build your own custom Linux distribution](./build-custom-distro.md).
- Store files in an isolated Linux file system, specific to the installed distribution.
- Run command-line tools, such as BASH.
- Run common BASH command-line tools such as `grep`, `sed`, `awk`, or other ELF-64 binaries.
Expand Down
8 changes: 5 additions & 3 deletions WSL/basic-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ For example:
wsl --shutdown
```

Immediately terminates all running distributions and the WSL 2 lightweight utility virtual machine. This command may be necessary in instances that require you to restart the WSL 2 virtual machine environment, such as [changing memory usage limits](/windows/wsl/disk-space) or making a change to your [.wslconfig file](./manage.md#).
Immediately terminates all running distributions and the WSL 2 lightweight utility virtual machine. This command may be necessary in instances that require you to restart the WSL 2 virtual machine environment, such as [changing memory usage limits](/windows/wsl/disk-space) or making a change to your [.wslconfig file](./manage.md).

## Terminate

Expand All @@ -168,8 +168,10 @@ To terminate the specified distribution, or stop it from running, replace `<Dist

## Identify IP address

- `wsl hostname -i` for the IP address of your Linux distribution installed via WSL 2 (the WSL 2 VM address)
- `cat /etc/resolv.conf` for the IP address of the Windows machine as seen from WSL 2 (the WSL 2 VM)
- `wsl hostname -I`: Returns the IP address of your Linux distribution installed via WSL 2 (the WSL 2 VM address)
- `ip route show | grep -i default | awk '{ print $3}'`: Returns teh IP address of the Windows machine as seen from WSL 2 (the WSL 2 VM)

For a more detailed explanation, see [Accessing network applications with WSL: Identify IP Address](./networking.md#identify-ip-address).

## Export a distribution

Expand Down
10 changes: 7 additions & 3 deletions WSL/faq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
metadata:
title: FAQ's about Windows Subsystem for Linux
description: "Find answers to frequently asked questions (FAQs) about the Windows Subsystem for Linux, such as 'What can I do with WSL?'."
keywords: BashOnWindows, bash, wsl, windows, windowssubsystem, faq
ms.date: 11/20/2023
ms.date: 07/16/2024
ms.topic: faq
ms.localizationpriority: high
title: Frequently Asked Questions about Windows Subsystem for Linux
Expand Down Expand Up @@ -167,7 +166,7 @@ sections:
- question: |
Can I use WSL for production scenarios?
answer: |
WSL has been designed and built to use with inner loop development workflows. There are design features in WSL that make it great for this purpose but may make it challenging for production-related scenarios compared to other products. Our goal is to make clear how WSL differs from a regular VM environment, so you can make the decision on whether it fits your business needs.
Yes, however WSL has been designed and built to use with inner loop development workflows. There are design features in WSL that make it great for this purpose but may make it challenging for production-related scenarios compared to other products. Our goal is to make clear how WSL differs from a regular VM environment, so you can make the decision on whether it fits your business needs.
The main differences between WSL and a traditional production environment are:
Expand Down Expand Up @@ -209,8 +208,13 @@ sections:
wsl --unregister <Distroname>
# Import your VHD backup
wsl --import-in-place <Distroname> <Install Location with filename>
# Set your default user account
You can set up your default user account by [setting a wsl.conf value of user.default=<name>](/windows/wsl/wsl-config#user-settings)
- name: WSL 2
questions:
Expand Down
2 changes: 1 addition & 1 deletion WSL/filesystems.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ We recommend against working across operating systems with your files, unless yo

For example, when storing your WSL project files:

- Use the Linux file system root directory: `\\wsl$\Ubuntu\home\<user name>\Project`
- Use the Linux file system root directory: `/home/<user name>/Project`
- Not the Windows file system root directory: `/mnt/c/Users/<user name>/Project$` or `C:\Users\<user name>\Project`

When you see `/mnt/` in the file path of a WSL command line, it means that you are working from a mounted drive. So the Windows file system C:/ drive (`C:\Users\<user name>\Project`) will look like this when mounted in a WSL command line: `/mnt/c/Users/<user name>/Project$`. It is possible to store your project files on a mounted drive, but your performance speed will improve if you store them directly on the `\\wsl$` drive.
Expand Down
1 change: 1 addition & 0 deletions WSL/install-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ There are some scenarios in which you may not be able (or want) to, install WSL
If the Microsoft Store app is not available, you can download and manually install Linux distributions using these links:

- [Ubuntu](https://aka.ms/wslubuntu)
- [Ubuntu 24.04](https://wslstorestorage.blob.core.windows.net/wslblob/Ubuntu2404-240425.AppxBundle)
- [Ubuntu 22.04 LTS](https://aka.ms/wslubuntu2204)
- [Ubuntu 20.04](https://aka.ms/wslubuntu2004)
- [Ubuntu 20.04 ARM](https://aka.ms/wslubuntu2004arm)
Expand Down
44 changes: 43 additions & 1 deletion WSL/networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,56 @@
title: Accessing network applications with WSL
description: Learn about the considerations for accessing network applications when using Windows Subsystem for Linux (WSL).
keywords: wsl, Linux, Windows, networking, ip address, ip addr, host IP, server, network, localhost, local area network, lan, ipv6, remote
ms.date: 11/15/2023
ms.date: 07/16/2024
ms.topic: article
---

# Accessing network applications with WSL

There are a few considerations to be aware of when working with networking apps and WSL. By default WSL uses a [NAT based architecture](#default-networking-mode-nat), and we recommend trying the new [Mirrored networking mode](#mirrored-mode-networking) to get the latest features and improvements.

### Identify IP address

There are two scenarios to consider when identifying the IP address used for a Linux distribution running via WSL:

**Scenario One:** From the perspective of the Windows host, you want to query a Linux distribution's IP address running via WSL2, so that a program on Windows host can connect to a server program running inside the distribution (instance).

The Windows host can use command:

```
wsl -d <DistributionName> hostname -I
```

If querying the default distribution, this part of the command designating the distribution can be omitted: `-d <DistributionName>`. Be sure to use a capital `-I` flag and not a lower-case `-i`.

Under the hood, host command `wsl.exe` launches the target instance and executes Linux command `hostname -I`. This command then prints the IP address of the WSL instance to `STDOUT`. The `STDOUT` text content is then relayed back to wsl.exe. Finally, wsl.exe displays that output to the command line.

A typical output might be:

```powershell
172.30.98.229
```

**Scenario Two:** A program running inside a Linux distribution via WSL2 (instance) wants to know the Windows host's IP address, so that a Linux program can connect to a Windows host server program.

The WSL2 Linux user can use command:

```bash
ip route show | grep -i default | awk '{ print $3}'
```

A typical output might be:

```
172.30.96.1
```

So the `172.30.96.1` is the host IP address for Windows, in this example.

> [!NOTE]
> These above IP address querying action is typically required when WSL2 is running with the default [NAT network mode](#default-networking-mode-nat).
> When the WSL2 is running with the new [mirrored mode](#mirrored-mode-networking), the Windows host and WSL2 VM can connect to each other using `localhost` (127.0.0.1) as the destination address, so the trick of using a query peer's IP address is not required.
## Default networking mode: NAT

By default, WSL uses a NAT (Network Address Translation) based architecture for networking. Keep the following considerations in mind when working with a NAT-based networking architecture:
Expand Down
20 changes: 8 additions & 12 deletions WSL/use-custom-distro.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,25 @@ In this example, we'll use Docker inside of a WSL distribution to obtain the tar

1. Open the command line (Bash) for a Linux distribution that you've already installed from the Microsoft Store (Ubuntu in this example).

2. Start the Docker service:

```bash
sudo service docker start
```
2. Ensure you have Docker Desktop running (Or if you have Docker installed in the WSL distro start the service with `sudo service docker start` )

3. Run the CentOS container inside Docker:

```bash
docker run -t centos bash ls /
docker run -t --name wsl_export centos ls /
```

4. Grab the CentOS container ID using grep and awk:
4. Export the container ID to a tar file on your mounted c-drive:

```bash
dockerContainerID=$(docker container ls -a | grep -i centos | awk '{print $1}')
docker export wsl_export > /mnt/c/temp/centos.tar
```

5. Export the container ID to a tar file on your mounted c-drive:
5. Clean up the container

```bash
docker export $dockerContainerID > /mnt/c/temp/centos.tar
```
```bash
docker rm wsl_export
```

![Example of running the commands above](./media/run-any-distro-tarfile.png)

Expand Down
17 changes: 9 additions & 8 deletions WSL/wsl-config.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Advanced settings configuration in WSL
description: A guide to the wsl.conf and .wslconfig files used for configuring settings when running multiple Linux distributions on Windows Subsystem for Linux.
ms.date: 01/17/2024
ms.date: 07/16/2024
ms.topic: article
ms.custom: seo-windows-dev
adobe-target: true
Expand Down Expand Up @@ -218,14 +218,15 @@ This file can contain the following options that affect the VM that powers any W
| swapFile | path | `%USERPROFILE%\AppData\Local\Temp\swap.vhdx` | An absolute Windows path to the swap virtual hard disk. |
| pageReporting | boolean | `true` | Default `true` setting enables Windows to reclaim unused memory allocated to WSL 2 virtual machine. |
| guiApplications | boolean | `true` | Boolean to turn on or off support for GUI applications ([WSLg](https://github.com/microsoft/wslg)) in WSL.|
| debugConsole | boolean* | `false` | Boolean to turn on an output console Window that shows the contents of `dmesg` upon start of a WSL 2 distro instance. Only available for Windows 11.|
| nestedVirtualization | boolean* | `true` | Boolean to turn on or off nested virtualization, enabling other nested VMs to run inside WSL 2. Only available for Windows 11.|
| vmIdleTimeout | number* | `60000` | The number of milliseconds that a VM is idle, before it is shut down. Only available for Windows 11.|
| dnsProxy | bool | true | Only applicable to networkingMode = NAT. Boolean to inform WSL to configure the DNS Server in Linux to the NAT on the host. Setting to false will mirror DNS servers from Windows to Linux. |
| debugConsole* | boolean | `false` | Boolean to turn on an output console Window that shows the contents of `dmesg` upon start of a WSL 2 distro instance. Only available for Windows 11.|
| nestedVirtualization* | boolean | `true` | Boolean to turn on or off nested virtualization, enabling other nested VMs to run inside WSL 2. Only available for Windows 11.|
| vmIdleTimeout* | number | `60000` | The number of milliseconds that a VM is idle, before it is shut down. Only available for Windows 11.|
| dnsProxy | boolean | true | Only applicable to networkingMode = NAT. Boolean to inform WSL to configure the DNS Server in Linux to the NAT on the host. Setting to false will mirror DNS servers from Windows to Linux. |
| networkingMode** | string | NAT | If the value is `mirrored` then this turns on mirrored networking mode. Default or unrecognized strings result in NAT networking. |
| firewall** | bool | true | Setting this to true allows the Windows Firewall rules, as well as rules specific to Hyper-V traffic, to filter WSL network traffic. |
| dnsTunneling** | bool | true | Changes how DNS requests are proxied from WSL to Windows |
| autoProxy* | bool | true | Enforces WSL to use Windows’ HTTP proxy information |
| firewall** | boolean | true | Setting this to true allows the Windows Firewall rules, as well as rules specific to Hyper-V traffic, to filter WSL network traffic. |
| dnsTunneling** | boolean | true | Changes how DNS requests are proxied from WSL to Windows |
| autoProxy* | boolean | true | Enforces WSL to use Windows’ HTTP proxy information |
| defaultVhdSize | size | `1TB` | Set the Virtual Hard Disk (VHD) size that stores the Linux distribution (for example, Ubuntu) file system. Can be used to limit the maximum size that a distribution file system is allowed to take up. |

Entries with the `path` value must be Windows paths with escaped backslashes, e.g: `C:\\Temp\\myCustomKernel`

Expand Down

0 comments on commit 2973cc4

Please sign in to comment.