Question

The ping utility works above the network layer and DNS works in the application layer.

If we try ping www.google.com, how does it resolve the IP address of GOOGLE since the DNS is above these layers?

Was it helpful?

Solution

ICMP (the protocol) may operate above IP, alongside TCP but a ping program itself almost certainly still uses the normal methods for name resolution, be that DNS, hosts file or resolv.conf.

For example, the ping program located here calls on gethostbyname() to turn DNS names into IP addresses.

OTHER TIPS

Certainly on windows computers, ping also uses LLMNR (Link-Local Multicast Name Resolution) to perform hostname resolution. A host may be pinged just fine while other services still fail if a computer is only known by LLMNR and the failing service relies on DNS. Vice versa: DNS may work but ping fails

Hostnames are still resolved through DNS, after that ping uses ICMP for the actual communication. You can try changing the DNS configs to invalid servers and see that ping won't work with hostnames.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top