We now need to add a 'Custom' inbound rule in Windows Defender Firewall. The following screenshots show the steps for adding this rule. You can use all the default settings preselected by Windows Defender Firewall except for the Step 3.4 (Scope) where you need to enter an allowed IP range.
3.1 Rule Type
Windows Defender Firewall doesn't seem to support setting an IP range if a specific program is selected. Also, since X410 is a Microsoft Store app, you shouldn't actually try to access its executable; Windows purposefully hides Microsoft Store app installation folders in order to improve Windows security as well as its app update process.
Anyhow, this shouldn't be of any problem for our needs as our new rule only allows connections from WSL2 to any publicly opened app running in Windows such as X410 with its 'Public Access' option enabled.
3.3 Protocols and Ports
In this step, instead of using the default settings, you need to specify local IP addresses for WSL2. As mentioned above, Windows seems to be using IP addresses between 172.16.0.0 and 172.31.255.255 for WSL2 and Hyper-V virtual machines. You can use a shortened notation of those IP addresses, i.e., "172.16.0.0/12" for this option.
You can enter any name for this option. We used "X410 Public Access for WSL2 Only" for our new rule.
Your computer with X410 and WSL2 running
Unknown computer somewhere
As mentioned in Step 3.2, this newly added rule is not only applied to X410 but also applied to all other publicly opened apps running in Windows. So, if you want to protect an app that needs to be connected from WSL2, you can now simply disable its Windows Defender Firewall public access rules; you should be able to find such rules similar to the ones shown in Step 2 for X410.