← Back to team overview

enterprise-ubuntu team mailing list archive

Questions: "ip-address hostname" in /etc/hosts

 

Hello,

/etc/hosts in ubuntu contains normally one entry 127.0.0.1 localhost and
127.0.1.1 hostname, but I would like to have "ip-address hostname"
in /etc/hosts.

How can I change the /etc/hosts, so that my system name is resolved to my
actual DHCP IP address.

Is a Script /etc/dhcp/dhclient-enter-hooks.d/  the right and
sustainable/reliable solution.

A Script doing like

sed -e "s/^127.0.1.1.*/$ip $hostname.$domain $hostname" /etc/hosts

regards,
Florian