This is a tracking/feedback issue for the common request of supporting The Nmap Security Scanner using Windows Subsystem for Linux (WSL). Obviously we already have an official native Windows build which works well, but WSL users may want to use Nmap in that environment too. I haven't played with this new Windows feature yet, but my understanding is that Nmap does not currently work with it, probably due to raw socket limitations. Here are some notes:
This tracking issue can be used by anyone with information to add about using Nmap on WSL in the hope that we'll be able to fully support it some day. At least assuming that Microsoft continues to support and improve WSL.
I have heard that Nmap works correctly on WSL2 (currently only available in Windows 10 Insider Preview), though I have not tested it myself. We currently issue a warning if WSL is detected (uname -r contains "Microsoft"), but do not attempt any change in behavior.
It seems to me that it is incumbent upon the developers of WSL to introduce changes that would better support Nmap, rather than the other way around.
Thanks for the note about WSL2. That is great news if it turns out to work with Nmap. And I agree that the best solution would be for WSL/WSL2 compatability to improve to the point where we and other Linux applications don't need to do anything special to support it. I haven't tried WSL2 (or even plain WSL) yet, but I'm looking forward to it. Currently I use Cygwin instead along with the native nmap.exe.
I think the secret with WSL2 is that it's a Linux kernel running in a VM rather than the Linux system call interface implemented atop the NT kernel plus a session manager process. The latter might not include support for PF_PACKET sockets for sniffing; the former presumably does, as you have a Linux kernel.
I'm currently trying to make all the tools work on WSL and let me tell you, some things need tweeking. Nmap as in its current state doesn't work on WSL. You can make it run by installing the Windows version and making an alias path for your specific Linux OS -> I tried it, and it works.
Remember to Disable the Npcap adapter if you're in network engineering [some discovery tools don't work with the Npcap adapter enabled (tools don't know the difference between the virtual interfaces and native interfaces(wifi, eth)].
Cheers!
Most helpful comment
I'm currently trying to make all the tools work on WSL and let me tell you, some things need tweeking. Nmap as in its current state doesn't work on WSL. You can make it run by installing the Windows version and making an alias path for your specific Linux OS -> I tried it, and it works.
Remember to Disable the Npcap adapter if you're in network engineering [some discovery tools don't work with the Npcap adapter enabled (tools don't know the difference between the virtual interfaces and native interfaces(wifi, eth)].
Cheers!