ping prints ip address octets backwards on host redirect

Bug #1892108 reported by Åge Strand
This bug affects 15 people
Affects Status Importance Assigned to Milestone
iputils (Ubuntu)

Bug Description

Description: Ubuntu 20.04.1 LTS
Release: 20.04

Just noticed a weird thing with ping on Ubuntu 20.04, which I recently updated to.

This is what I get when pinging a host on my network:

user@ubuntu2004:~$ ping
PING ( 56(84) bytes of data.
From icmp_seq=2 Redirect Host(New nexthop:

The ubuntu2004 machine is located in the 10.15.0.x network. is a DSL router. is a firewall between multiple networks. is a machine on a different local network.

All traffic not destined for the internet is routed from to, so I would expect the printout to read "New nexthop:".

However, as you can see this is not the case. Instead the octets are printed in reverse order.

To verify this I tried the same on another machine in the same network, running Ubuntu 18.04:

user@ubuntu1804:~$ ping
PING ( 56(84) bytes of data.
From icmp_seq=2 Redirect Host(New nexthop:

As you can see, the printout is correct here: "New nexthop:"

I further verified the discrepancy by using tcpdump to interpret the ICMP packets on the ubuntu2004 machine, and there seems to be no problem for tcpdump to display the correct IP address.

My assumption is that there is something wrong in the print function which displays the IP address for a host redirect.

Revision history for this message
Åge Strand (aagestrand) wrote :

Possible culprit might be the pr_icmph function in ping.c, lines 1250 - 1259:

   struct sockaddr_in sin = {
    .sin_family = AF_INET,
    .sin_addr = {
     icp ? icp->un.gateway : info

   printf(_("(New nexthop: %s)\n"), pr_addr(&sin, sizeof sin));

Are you sure the variables used for .sin_addr input are guaranteed to be in network byte order?

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in iputils (Ubuntu):
status: New → Confirmed
Revision history for this message
Mike Bergeron (clandestiny) wrote :

I'm afraid it likely runs a bit deeper than just being "printed in reverse order". I had a Redirect Host of print backwards and actually name resolve ( and thereafter ping returns ceased, ostensibly because it tried to route my private addresses through some dsl client in Seattle. It's now November, and a fresh install of Focal 20.04.1 still has this problem, reported in August. It might be obscure, but it's not trivial.

I hope someone is working on this.


Revision history for this message
Silvan Diem (linuxfighter) wrote :

Please fix it asap.
We have the same issue. We have migrated our Nagios to Ubuntu 20.04. Now we have flapping hosts, because of this issue!

Is there a timeline when you will able to fix it ?



Revision history for this message
Richard Laager (rlaager) wrote :

I was able to verify this is fixed in iputils-ping 20210202-1. That is, I saw this same problem, grabbed those sources from Debian, built them, and tested again. Accordingly, this should already be fixed in Ubuntu impish.

Revision history for this message
Steve Dodd (anarchetic) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers