How can a Raspberry Pi communicate with PX4-Autopilot running in WSL (Windows Subsystem for Linux) using UDP?

Hello PX4 community,

I am currently working on a system where I run PX4-Autopilot (SITL) inside WSL2 on a Windows 11 PC, and I want to establish communication between this PX4 instance and a Raspberry Pi over UDP (MAVLink).


System setup:

  • PX4-Autopilot SITL running in WSL2 (Windows 11)
  • Raspberry Pi (Linux) running companion-side scripts (MAVSDK / custom Python)
  • Both devices are connected to the same local network (LAN)
  • Communication method: MAVLink over UDP

Goal:

I would like the Raspberry Pi to:

  • Send MAVLink messages to PX4 in WSL
  • Receive telemetry back from PX4
  • Eventually support offboard control or swarm-style messaging between multiple nodes

Problem:

Since PX4 is running inside WSL2, it is not directly reachable on the LAN like a normal Linux machine. I understand that WSL2 uses NAT networking and its IP address is dynamic.

I am unsure about the correct and stable way to:

  • Expose PX4 UDP ports from WSL to the local network
  • Allow the Raspberry Pi to connect reliably to PX4 SITL
  • Avoid issues caused by changing WSL IP addresses

What I have already tried:

1. WSL “mirrored networking” mode

I tried enabling WSL mirrored networking mode, which does make WSL reachable on the LAN.

However, this introduced other issues in my PX4 workflow:

  • I can no longer properly run VSCode Remote - WSL
  • PX4 SITL command like make px4_sitl gz_x500 becomes unstable or fails in my environment
  • Some Gazebo / GUI-related components do not start correctly

Because of these limitations, mirrored mode is not a practical solution for my current PX4 development setup.


Questions:

  1. What is the recommended way to expose PX4 SITL (running in WSL2) to external devices via UDP in a stable way?
  2. Is MAVLink Router the correct approach for bridging WSL2 and external LAN devices like a Raspberry Pi?
  3. Are there any best practices for handling WSL2 networking limitations in PX4 development setups?
  4. Besides mirrored mode, are there other reliable architectures used in PX4 development for multi-device UDP communication?

Any guidance, example configurations, or recommended architectures would be greatly appreciated.

Thank you!