WSL: nmap not working

yashar@DESKTOP-MHBRT96:~$ sudo nmap -sP 192.168.1.0/24 Starting Nmap 6.40 ( http://nmap.org ) at 2016-11-11 23:37 STD route_dst_netlink: cannot bind AF_NETLINK socket: Invalid argument

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 196
  • Comments: 94 (12 by maintainers)

Most upvoted comments

@lab1005 That’s partially because AF_PACKET family is not supported yet. You may upvote this to speed up the process…

Edited: official Uservoice issue https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/17817685-support-af-packet-address-family-tcpdump-wireshar

This is marked as closed but is not resolved…?

You just described Microsoft business model

Any news about the nmap feature ?

What is the roadmap for this issue?

nmap, wireshark and many other tools that use AF_PACKET are very used. The lack of this feature is really blocking.

When I saw that Kali Linux had been released then I figured that this had most likely been sorted out. Kali Linux without the ability to scan a network is not very useful at all.

Hello people (I’m looking at you @eaglegeek-cts)., please stop pinging this thread if it’s not with news/updates, but instead add 👍 or upvote https://wpdev.uservoice.com/forums/266908-command-prompt-console-windows-subsystem-for-l/suggestions/17817685-support-af-packet-address-family-tcpdump-wireshar

Many people are subscribed to this thread to have news, and not user-related messages !

Adding anymore “Oh please add it”, or “+1” is useless (there are already plenty in this thread), and everyone (including Microsoft) is aware that this feature would be nice. All we need to do now is wait.

I don’t want the thread to be closed by a mod, because of how boring it has become 😕

@tara-raj & the team will update y’all if and when AF_UNIX support arrives in Windows.

Thanks for the discussion here everyone.

@yonailo Know that we do care deeply that WSL still has some gaps and use-cases that require attention. Also, note that, as @therealkenc points out, we’ve previously stated that we’re dependent on other teams making changes in their code to realize support for nmap and other affected features.

This is a complex issue to solve because Windows has restricted non-admin apps from opening raw sockets since XP SP2, in order to prevent a repeat of to DoS and other attacks that resulted in these restrictions being introduced in the first place.

This said, Windows DOES support raw sockets, and there are several raw socket drivers including those used by Microsoft Message Analyzer, and WinPCap (https://www.winpcap.org/) used by 1WireShark, for example.

Bear with us while we work diligently through these issues.

Thanks.

(Please don’t spam this, it does nothing)

i just installed creators update and did a clean install to WSL and nmap is still not working

~$ sudo nmap -sP 192.168.1.0/24

Starting Nmap 7.01 ( https://nmap.org ) at 2017-04-12 15:33 STD
dnet: Failed to open device wifi0
QUITTING!

Since the release of Kali Linux in the Windows Store, this is getting more attention. Hopefully an update will come soon.

One would think that Wireshark, Tshark and Nmap could be considered default requirements in an enterprise environment?

it is unrealistic to expect this issue to be fixed in WSL1 when microsoft is clearly going the WSL2 way. unsubscribing from this spam.

Why ppl like Linux because Linux has fewer restrictions, people can do more what they want to do. Please don’t bring the limit from windows to the WSL.if only can do the windows can do,why we should be use WSL?

Soo,when could be the problem soloved?

https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/17817685-support-af-packet-address-family-tcpdump-wireshar

that has 1426 votes now ? how many votes need ?

@therealkenc ty for the interesting remark: “WSL’s focus is on development related scenarios, not enterprise scenarios (for some definition of either category).” TL;DR: Is there a blog post that describes this distinction in more detail, perhaps with more compelling use cases than https://msdn.microsoft.com/en-us/commandline/wsl/faq ?

Detailed comments, questions; I’ve been really excited by WSL and am trying to figure out for myself how /when I can use it. (I have a windows machine I love, but my current shop is mac based. ) I already think Powershell’s Bash sugar support is terrific.

Perhaps this is really a marketing / product placement question that apparently many of us share. If so , maybe you all can clarify and show us the win(s).

The idea of WSL focusing on dev not enterprise scenarios confuses me.

  • For pure ‘development,’ ie writing code, I can do that almost anywhere with a text editor nowadays.
  • For certain coding, like simple bash scripts, windows powershell already provides some interop with linux - no WSL required, right? (or maybe it is/was?)
  • The FAQ for WSL, above, references MS’s desire to support dev on ruby stacks that use long filepaths and such. Are those scenarios satisfactorily solved without networking, ie this ticket #1349 , fully supported? [1]
  • The WSL FAQ states an intent not to support server tasks and references other tools like Docker, but aren’t alot of the complex ruby programs related to server usage? In fact, isn’t it exactly Linux’s ‘free enterprise services’ such as nmap, tcpdump, etc that got it into the market(s) (of RubyRails hosting for ex.)? As one anonymous poster wrote on the UserVoice, above, November 24, 2017 17:43 "we use linux because we are nerds; dev nerds, infra nerds, network nerds, or all of the above. " That rings true to me, and I’m wondering what dev projects I should/not think of with WSL.

Your complaint is well taken that Uservoice is lacking and ’ absent a single: “In my development workflow I do <insert your scenario>, but I am unable to to <thing> because there is no AF_PACKET support in WSL”. In this context <thing> is a development goal you are trying to achieve, not “run native Linux wireshark” (which is a means not a goal). ’

I checked and found the most substantial comments were:

  • James commented July 30, 2017 22:54 Pls support, don’t want to have to run a VM to get these tools to work, kinda meant to be able to replace the need to have a VM to get a real Linux CLI… => this is the same concern as on this issue ticket, ie we thought WSL would replace needing also to have a VM. But here James doesn’t say why he wants to use it.
  • Anonymous March 19, 2017 12:12 Yes, +1. Every few months I try out the latest Linux subsystem on my wifes laptop to see if it can replace my MacBook for mobile development. As of now, it can’t. I develop apps that use libpcap and/or netmap on Linux. The great thing is, they compile and I can read from pcap files files. Its just when I want to do a "live " test it fails.

Some thoughts as an observer about the use case are above, but also once there are daemons [2], how about this scenario;

  • I start my dev ruby rails server on my linux box, it runs in background after I hide wsl
  • now periodically I want to check its network performance.
  • would I not need nmap etc on WSL to do so?
  • Similarly, or for the same scenario, if the website/process is a dockerized container , wouldn’t I need these tools?

Since the FAQ seems to say I should never do this, I want the FAQ to specify more of the advantages of MS’s proposed division of labor.

thank you for the project! I am definitely speaking as an amateur / explorer here so all/any resources appreciated. Anne

Notes [1] NB: Right now 2017-12-06 those scenarios might have some trouble as well , iff the files-intermittently-missing is not fixed completely by the latest update. I am not sure if it is - maybe no per #2712 but maybe yes per #2448 .

[2] Server work likely wouldn’t make sense before getting background processes going, https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/13653522-consider-enabling-cron-jobs-daemons-and-backgroun

//edit; add TLDR , reorg

I have come to realise this. But in the bigger picture of things it’s just simpler to wipe my windows and install Kali with windows running as a vm. Just thought it would have made life simpler with default OS and bash implemented. Oh well, Cest la vie.

@JasonLinMS as FYI @rtfmoz - Thanks for the trace. From the trace it looks like it relies on the NETLINK_ROUTE\RTM_GETROUTE message with the given <destination ip address>, which we haven’t yet implemented. I have opened a bug to track this internally.

/bump /sub

出现了这个问题: Warning: Nmap may not work correctly on Windows Subsystem for Linux.

This issue still not resolved? But already closed?

Please add AF_PACKET support! Many people need to use this for their work, and windows must have this to be competitive with macos and linux for development work.

yes please fix this and you will make a lot of people happier !!

/sub

Any updates are appreciated

@abdilahrf - Nothing new to report right now. You’ll likely hear here, and from @tara-raj’s Twitter when the team makes progress.

im waiting for this

Microsoft please support AF_PACKET for WSL that would be amazing!

This is marked as closed but is not resolved…?

Although not the solution that is being requested in this issue, a recent Medium post details a workaround: https://medium.com/@the4rchangel/nmap-in-the-windows-bash-shell-64cadff1a689

Basically, it boils down to:

alias nmap='"/mnt/c/Program Files (x86)/Nmap/nmap.exe"'

You can read the more in-depth explanation in the article above.

An nmap dev even called this approach “the Right Way” to get nmap working on WSL.

/bump

that’s a bummer(

/bump /sub

/bump /sub

You can try the Windows binaries; I have had a fairly good experience with tshark on Windows. But worst case here don’t go lugging around another physical machine unless you have unrelated reasons to do so. Wireshark in VirtualBox (which supports bridged promiscuous mode) works surprisingly well. For the time being, WSL’s focus is on development related scenarios, not enterprise scenarios (for some definition of either category). A VM might be a better fit for you for now, and there’s nothing wrong with that. Bonne chance.

When opening issues please fill out the provided template. Which windows build are you running?

@therealkenc - I get that this is a complex issue and is not closed as such but it being tracked elsewhere.

I was tracking it through this “issue” which is now closed and presumably will not be updated. Do you know where the new canonical place is that is tracking AF_PACKET support so I can subscribe to that and keep an eye on the status of the support?

This is a complex issue to solve because Windows

It think you might mean, it’s complicated.

Also, note that, as @therealkenc points out, we’ve previously stated that we’re dependent on other teams making changes in their code to realize support for nmap

That depends on far off road you’re willing or able to go. Unmodified Linux nmap running on WSL below. Just sayin’. 😉

image

Sorry for bothering you, it was not my intention. I think you shouldn’t care if people requesting a feature are coders or not, on the other hand, you should care if someone installs WSL, launches nmap and gets an error message. Probably those guys would have already abandoned windows at all, if they had a choice.

I understand that fixing this issue is not in your hands, so please don’t get upset at it.

Hopefully we’ll get an update soon

You may upvote this to speed up the process…

@gpotter2 The ‘this’ link just goes to a Forbidden page?

where is nmap

You will note the year 2020 for proper release of the integration. 😃 I note and appreciate the nudge. Unfortunately many of us have to run vmware workstation right now and are heavily dependent on it. Deploying wsl2 is a breaking change.

@Nikko : in wsl 2.0 (currently on the insider fast ring afaik), I believe the issue is no longer relevant as the way wsl is running the nix kernel fully virtualized within the Windows kernel.

Please work on this!

This is important fix!

This is already what I do for nmap, but many other tools and business or personal developments are not available in Windows version. The lack of this feature is really blocking.

I’d be really really helpful if you guys had nmap in linux and could use raw sockets. I for one consider using another platform just for Nmap.

https://wpdev.uservoice.com/forums/266908-command-prompt-console-windows-subsystem-for-l/suggestions/17817685-support-af-packet-address-family-tcpdump-wireshar is not a valid link anymore. Any alternatives?

$ sudo mv /usr/bin/nmap /usr/bin/nmap-really
$ # use your own path to Windows nmap.exe, natch
$ sudo ln -s "/mnt/c/Program Files (x86)/Nmap/nmap.exe" /usr/bin/nmap

May I ask if above workaround would help me use wireshark in WSL? Thanks!

Pinging this

My work around (inspired by @therealkenc comment on using Win binary)

  • Install Windows Nmap.
  • Create a bash script to call the windows binary.
[~]$ which nmap
/usr/sbin/nmap
[~]$ cat /usr/sbin/nmap
#!/bin/bash

"/mnt/c/Program Files (x86)/Nmap/nmap.exe" "$@"

Other than that, I’d say, use a VM or a native Linux.

System: win10

Subsystem: Kail

Network card type: wireless network card dnet: Failed to open device wif0 Can you tell me how to solve it

default

This is a complex issue to solve because Windows It think you might mean, it’s complicated.

thumbs up

This does work for direct nmap usage but other things like Metasploit/db_nmap will still not work.

Not with an alias. But you can try:

$ sudo mv /usr/bin/nmap /usr/bin/nmap-really
$ # use your own path to Windows nmap.exe, natch
$ sudo ln -s /mnt/c/Users/there/source/nmap/nmap-7.70/mswin32/Release/nmap.exe /usr/bin/nmap

AFAIK metasploit just spawns nmap. YRMV, I haven’t tried it. “Use Windows nmap for now” is what I have been trying to communicate since last year (analogy being WSL web developers using Windows Chrome). I guess it needed to be put in blog form.

Do one more of those.

This issue# is an ask for a MSFT branded winpcap / npcap / Win10pcap device driver re-implementation. If the functionality existed In Windows then npf.sys wouldn’t be necessary. And, if MSFT did re-implement npf.sys, then consumers of nmap would end up in exactly the same place you are now: the equivalent of nmap.exe with interop. Which you have.

Notwithstanding the tautological reasoning that AF_PACKET coders can’t do AF_PACKET programming without AF_PACKET of course. But none of the 14 (!) people who (mind mindbogglingly) upvoted the AF_UNIX post in this thread are such coders, now are they. Such coders exist but you are probably not one of them.

This is on the backlog. Sunil already stated in (uncharacteristically) unequivocal terms:

Most of the work needed for that lies outside the immediate WSL scope and as @therealkenc has also stated above, we are tracking them. Please bear with us till then.

Maybe that status changes next week. Maybe it changes in two years. You will hear about it when it does. Until then, please stop.

@DarthSpock - Correct, AF_UNIX does not has any place in this issue. So, if you can post your question in the other post, I am happy to discuss them there. Or, even better, start a new thread or comment on the blog post.

As for AF_PACKET, we definitely understand the demand for it. Most of the work needed for that lies outside the immediate WSL scope and as @therealkenc has also stated above, we are tracking them. Please bear with us till then.

@abdilahrf, @rtfmoz - See the blog post on AF_UNIX here

“AF_UNIX will come.” ~ Thinker by Rodin

On Sat, Dec 23, 2017 at 10:16 PM, Abdillah Hasny notifications@github.com wrote:

im waiting for this

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/WSL/issues/1349#issuecomment-353720745, or mute the thread https://github.com/notifications/unsubscribe-auth/ADN9GbjkkqNTFtCev-SE120-jFyXDRmDks5tDOEKgaJpZM4KwGOP .

Well I can answer that one easily, I use tcpdump, tshark nmap in my day to day tasks. Having this on one machine instead of having a separate machine will save me a ton of time as well as having to lug more than one machine around. I will try what was stated above to install windows binaries and stick it in the path. Not sure if it will work or not.

An acceptable workaround is just to put the Windows version of nmap in your path somewhere.