From 2973cc44eb38e63c05833416fb5aa6c1cdff4a45 Mon Sep 17 00:00:00 2001 From: Matt Wojciakowski Date: Tue, 16 Jul 2024 16:01:18 -0700 Subject: [PATCH] Main > Live (#1986) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 * 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 * 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 * 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 --------- Co-authored-by: Craig Loewen Co-authored-by: Keith Horton Co-authored-by: Cătălin Emil Fetoiu Co-authored-by: Catalin-Emil Fetoiu Co-authored-by: FantasqueX Co-authored-by: Joshua Cooper Co-authored-by: Ben Hillis Co-authored-by: Jimm Chen <38829153+chjfth@users.noreply.github.com> --- WSL/about.md | 2 +- WSL/basic-commands.md | 8 +++++--- WSL/faq.yml | 10 ++++++--- WSL/filesystems.md | 2 +- WSL/install-manual.md | 1 + WSL/networking.md | 44 +++++++++++++++++++++++++++++++++++++++- WSL/use-custom-distro.md | 20 ++++++++---------- WSL/wsl-config.md | 17 ++++++++-------- 8 files changed, 75 insertions(+), 29 deletions(-) diff --git a/WSL/about.md b/WSL/about.md index 1df9de93..5d653f31 100644 --- a/WSL/about.md +++ b/WSL/about.md @@ -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. diff --git a/WSL/basic-commands.md b/WSL/basic-commands.md index 3359fd25..d98a3401 100644 --- a/WSL/basic-commands.md +++ b/WSL/basic-commands.md @@ -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 @@ -168,8 +168,10 @@ To terminate the specified distribution, or stop it from running, replace ` # Import your VHD backup + wsl --import-in-place + # Set your default user account + + You can set up your default user account by [setting a wsl.conf value of user.default=](/windows/wsl/wsl-config#user-settings) + - name: WSL 2 questions: diff --git a/WSL/filesystems.md b/WSL/filesystems.md index c565ba18..7d63ec93 100644 --- a/WSL/filesystems.md +++ b/WSL/filesystems.md @@ -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\\Project` +- Use the Linux file system root directory: `/home//Project` - Not the Windows file system root directory: `/mnt/c/Users//Project$` or `C:\Users\\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\\Project`) will look like this when mounted in a WSL command line: `/mnt/c/Users//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. diff --git a/WSL/install-manual.md b/WSL/install-manual.md index 47bee86d..cfffc970 100644 --- a/WSL/install-manual.md +++ b/WSL/install-manual.md @@ -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) diff --git a/WSL/networking.md b/WSL/networking.md index ae7ade5a..8eefbaae 100644 --- a/WSL/networking.md +++ b/WSL/networking.md @@ -2,7 +2,7 @@ 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 --- @@ -10,6 +10,48 @@ ms.topic: article 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 hostname -I +``` + +If querying the default distribution, this part of the command designating the distribution can be omitted: `-d `. 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: diff --git a/WSL/use-custom-distro.md b/WSL/use-custom-distro.md index 92132f75..cdf22e87 100644 --- a/WSL/use-custom-distro.md +++ b/WSL/use-custom-distro.md @@ -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) diff --git a/WSL/wsl-config.md b/WSL/wsl-config.md index 16f34389..ce69f228 100644 --- a/WSL/wsl-config.md +++ b/WSL/wsl-config.md @@ -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 @@ -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`