IP addresses with ::ffff: prefix are IPv6 addresses which are mapped to IPv4. Therefore ping resulting IPv4 address.
Cc: Tj <[email protected]> Signed-off-by: Petr Vorel <[email protected]> --- Based on idea contributed to iputils. https://github.com/iputils/iputils/commit/8ed7ffc999e2a541e06ee48faf26a323dfe487c2 Kind regards, Petr networking/ping.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/networking/ping.c b/networking/ping.c index b7e6955a9..7ed58f9d6 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -986,6 +986,14 @@ static int common_ping_main(int opt, char **argv) af = AF_INET; if (opt & OPT_IPV6) af = AF_INET6; + + struct in6_addr a6; + if (inet_pton(AF_INET6, hostname, &a6) && IN6_IS_ADDR_V4MAPPED(&a6)) { + hostname = strrchr(hostname, ':') + 1; + af = AF_INET; + printf("IPv4-Mapped-in-IPv6 address, using IPv4 %s\n", hostname); + } + lsa = xhost_and_af2sockaddr(hostname, 0, af); } #else -- 2.45.2 _______________________________________________ busybox mailing list [email protected] https://lists.busybox.net/mailman/listinfo/busybox
