Q:

Is there a way to determine machine hostname without touching "/etc/hosts"?

Considering that I'm in a LAN that assigns IP addresses using DHCP (and that I'm not its administrator), how do I set things up such that when I ping <hostname> (instead of ping <IP address>, I do get something back, without having added the match in "/etc/hostname")? Would I need to do this change in separate places for the web- and for ssh-server?
I'm wondering because I think there was a time when I could do this without any fiddling with "/etc/hosts" (or am I mistaken?). The problem with that file is that I would have to do it on every client that wants to use the name-to-IP mapping, and to have to continually change it if some IP address changes. 
The question really is: is there's a tool that can do network discovery of hostnames (matched to their IP addresses of course).

A:

Ideally, your sysadmin would have set up the network with a DNS server, and that DNS server would be dynamically updated with host names from DHCP. 
You might try to use the ICMP domain name messages to reap them, but I don't think that is widely 
implemented. 
Another, older method is NIS server. But these are not very common any more. You can try ypcat hosts and see if that returns you something.
Another is zeroconf, where hosts that support it broadcast their name and you can run a service that caches them (the Avahi package does this. If you have it set up then a ping <hostname>.local may work for you already. But not every node will support this either. you can also try querying with the avahi tools: avahi-resolve-host-name <hostname>.local and writing a script that updates /etc/hosts for you if the normal resolver doesn't work. 
So there is no other "magic" place to get host names from. Somebody is going to have to define that mapping, or make it dynamically discoverable. If your sysadmin did not or will not, then you have to do it. And the only place you can do it for your local machine is the /etc/hosts file.  So if none of the above methods work then you're stuck with that. Sorry.

