From a remote machine I am able to ping my computer by its IP address, but not by its hostname. How can I make it accessible by its hostname as well?

  • Just to clarify: you can ping your PC (from a different machine) via its IP, and fail doing so with using its hostname? – Fiximan Aug 25 '15 at 9:04
  • thanks for giving quick response i can ping my PC from different IP address. – shakeer akram Aug 25 '15 at 9:06
  • 2
    I just don't get you 100%: say your IP is and the hostname is linuxmachine. Then ping works and ping linuxmachine fails. Is that the problem? – Fiximan Aug 25 '15 at 9:08
  • 1
    exactly this is the problem I'm facing – shakeer akram Aug 25 '15 at 11:04

If I understand your problem correctly, you want to ping your computer from another computer. The ping works but the ping hostname doesn't. What I suspect the situation being is that your computer doesn't have a its hostname registered in DNS that is discoverable by the other machine.

If the hostname is not known to the other machine it does not know where to send the ping.

your ip =

your hostname = hostname

other computer ping -> your computer

other computer ping hostname -> unknown

you should set the other computer's hosts file so that it knows what hostname means. The hosts file is at /etc/hosts and needs to be edited while root. What you need to enter there is hostname, you can do this with command

# echo " hostname" >> /etc/hosts

and of course this needs to be entered in the other computer's hosts file.

If the two computers are connected to the same router you may edit the routers hosts the same way and then all the computers in the same network know each other by name. This is assuming that all the computers use the router as their DNS server. You may get more info of the DNS from wikipedia

| improve this answer | |
  • 1
    Thank you @steve of noting my typo. It is now corrected. – Iden Ilraldeduk Aug 25 '15 at 11:08
  • Thanks dear great experience now i can ping my remote computer through host name. i appreciate with your help – shakeer akram Aug 25 '15 at 20:58
  • No problem at all @shakeerakram . If this was the correct answer, would you mark it as accepted. – Iden Ilraldeduk Aug 26 '15 at 6:59

I am guessing you don't have your own DNS server. Computers understand IP addresses but not the name of your computer. To make it so, you need to either add a record in your hosts file, which can be found in /etc/hosts, or have a DNS entry on your DNS server. Then it will know what you mean by the hostname of your machine.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.