≡ Menu

Cannot ping hostname but can ping IP

Question – I have a Linux box in which I cannot ping domain names, but I can ping IP addresses. What could be the problem?

To be able to use host names or domain names, you need to have DNS configured on your Linux machine. DNS is a protocol that can convert a domain name (host name) to its IP addresses. All utilities like ping, use DNS servers to do this resolution from name to it’s IP address.

On Linux, you need to setup DNS by adding DNS servers to a special file which is as follows:


In this file, you need to put IP addresses of two or three DNS servers. For example, to use Google Public DNS, you need to add the following lines to /etc/resolv.conf:


Add these lines to your /etc/resolv.conf file and your name resolution will start working! You will now be able to use host names like google.com instead of their IP addresses.

Comments on this entry are closed.