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?
If I understand your problem correctly, you want to ping your computer from another computer. The ping 220.127.116.11 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 = 18.104.22.168
your hostname = hostname
other computer ping 22.214.171.124 -> 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
126.96.36.199 hostname, you can do this with command
# echo "188.8.131.52 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
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.