How does ping resolve ip addresses?

user1762571 picture user1762571 · Jun 18, 2013 · Viewed 7.1k times · Source

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?

Answer

paxdiablo picture paxdiablo · Jun 18, 2013

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.