Code in this video_ Assign a LAN IP to WSL2 on Windows

✳️ Replace the highlighted information with your own

[wsl2]
# Enable mirrored networking mode
networkingMode=mirrored

# Allow Windows Firewall to manage WSL ports
firewall=true

# Limit system resources to prevent freezing (Example: 8GB RAM machine)
memory=4GB
processors=4

[experimental]
# Improve IP mapping and loopback stability
hostAddressLoopback=true

# Automatically reclaim unused RAM from Linux
autoMemoryReclaim=gradual

# Automatically shrink virtual disk size (VHDX)
sparseVhd=true

Parameter Explanation

  • networkingMode=mirrored → Use mirrored networking so WSL shares the same LAN as Windows (no NAT, no port forwarding).
  • firewall=true → Let Windows Firewall control access to WSL ports (must open ports manually if needed).
  • memory=4GB → Limit WSL RAM usage to avoid system lag or freezing.
  • processors=4 → Limit the number of CPU cores used by WSL.
  • hostAddressLoopback=true → Improve localhost and IP communication between Windows and WSL.
  • autoMemoryReclaim=gradual → Automatically release unused RAM back to Windows over time.
  • sparseVhd=true → Automatically shrink the virtual disk (VHDX) to save storage space.

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *