Computer's (clients) hostname is stored in /etc/hostname, system first looks there and in /etc/hosts, order in which hostnames and stuff is resolved is in /etc/nsswitch.conf in line hosts: ... files mean files like /etc/hosts or /etc/hostname, /etc/resolv.conf, but after installing libnss-mdns, the line in nsswitch.conf should be like this:
Default desktop installation of Ubuntu has DNS resolving configured by default. If you for any reason install your Ubuntu from minimal installation or server edition, avahi-daemon (or mdnsresponder) is needed to be installed.
In small home network there is no need and reason to install and maintain DNS server, mDNS will automatically configure hostname resolving with IPs assigned by DHCP.
After installing libnss-mdns and reboot, it will be possible to ping a computer hostname inside LAN:
$ sudo apt-get install libnss-mdns
$ ping hostname.local
PING hostname.local (192.168.0.104) 56(84) bytes of data.
64 bytes from hostname.local (192.168.0.104): icmp_req=1 ttl=64 time=4.69 ms
64 bytes from hostname.local (192.168.0.104): icmp_req=2 ttl=64 time=3.92 ms
64 bytes from hostname.local (192.168.0.104): icmp_req=3 ttl=64 time=4.57 ms
64 bytes from hostname.local (192.168.0.104): icmp_req=4 ttl=64 time=2.03 ms
--- hostname.local ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 2.037/3.807/4.694/1.064 ms
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4