-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Failed to convert source address to presentation format" when using a specified interface that has both IPv4 and IPv6 addresses #2206
Comments
If you are in a position to compile Nmap then you could try this patch as a quick fix: --- a/libnetutil/netutil.cc 2020-11-25 19:23:26.400705564 -0700
+++ b/libnetutil/netutil.cc 2020-12-20 22:56:08.182980811 -0700
@@ -3163,7 +3163,7 @@
len -= NLMSG_LENGTH(sizeof(*nlmsg));
/* See rtnetlink(7). Anything matching this route is actually unroutable. */
- if (rtmsg->rtm_type == RTN_UNREACHABLE)
+ if (rtmsg->rtm_type == RTN_UNREACHABLE || rtmsg->rtm_type == RTN_UNSPEC)
return 0;
/* Default values to be possibly overridden. */ |
What appears to be going on is that in function Line 3202 in cd63da6
This rationale seems generally valid but it fails when the interface is determined upfront, via -e . In this case the interface info gets populated early:Line 3111 in cd63da6
instead of by parsing a route attribute: Line 3191 in cd63da6
Incorrect value of 1 is returned to function setup_target , which then proceeds with setting up the target, finally trying to convert the source IP address to a string via inet_ntop :Line 187 in cd63da6
This conversion fails because the requested family is AF_INET6 , while the content of struct sockaddr_storage is AF_UNSPEC (because it did not get populated by route_dst_netlink ).
The fix presented earlier avoids the issue by exiting early on |
The patch above, with additional route types |
The patch has been committed as r38183. Thank you for reporting the issue. |
Describe the bug
When I try to discover hosts that are not reachable from a specific interface, and the interface has both IPv4 and IPv6 addresses,
nmap
fails with:Moreover, if the argument is a list of IP addresses (some of them reachable), none of those hosts will be discovered because of the error.
To Reproduce
I'm including a script that reproduces the behavior with Docker CE (20.10.0 on Fedora 32 in my case).
Important: Make sure Docker assigns IPv4 addresses to the interfaces.
Expected behavior
A standard message saying that the host is down, or at least some hosts discovered in case of multiple IP addresses.
Version info (please complete the following information):
nmap --version
:nmap --iflist
Additional context
I observed this problem with a variety of OSs (containers) and nmap versions.
The text was updated successfully, but these errors were encountered: