Need to understand : ping
Solution 1:
Typically a trailing dot is used to denote that the hostname used is a fully qualified domainname (under the DNS root).
Appending the dot would prevent the search-domain from being appended to (short) hostnames in DNS lookups. Why it has the result it does in your examples with an IP-address, I don't know.
It may be that normally a hostname with a dot . also gets interpreted as a FQDN except when the decimal representation of an IP-address( four numbers [0-255] separated by dots) is detected, but that matching rule fails when the trailing dot is added to the ip-address.
If your search domain is example.com
and the A record for www.example.com.
exists:
ping www
should resolve to :
ping www.example.com.
and the A record of your webserver and result in some ICMP packets being sent to your webserver.
ping www.
will fail, because AFAIK there is no top-level domain www
Solution 2:
The trailing period changes it from an IP address that it just uses in numeric form to a domain name that it looks up using reverse address resolution (in-addr.arpa domain).