charlie_lab:
From your question I guess that you are trying to make the machine's hostname appear in the /etc/hosts file?
Hosts files aren't normally used for dynamic IP addresses, as they can become out of date, and "localhost" is always mapped to the local machine (albeit through the loopback interface not through the external network interface). Another option is to use a DNS server (
http://www.tldp.org/HOWTO/DNS-HOWTO.html).
It is still possible to update the hosts file from DHCP, but I couldn't find any examples on line, suggesting that it's a rather rare thing to do.
The software that gets your DHCP address from the router is called a DHCP client, and it needs to be set up to update the hosts file when your IP address changes. On Ubuntu (for example), you can add a script to the directory /etc/dhcp3/dhclient-exit-hooks.d/, and dhclient will run that script when your IP address changes.
Hope that helps,
—Robert J Lee