2015-12-02 Update
Newer versions of dhclient (in debian at least) come set with send host-name = gethostname();
which is enabled. If this is the case you should be all set with exposing your machine name on your network (given you want the exposed name the same as the machine name).
Background
Imagine you have a local network set up and would like all machines in the network to be accessible via DNS. This is a common task and involves pushing the machine name from each client to the DNS server via the ‘send host-name’ command in dhclient.
Details
To make this happen we need to do the following:
- edit
/etc/dhcp/dhclient.conf
- find the ‘send host-name ‘…’ line in the file (usually it is commented out) and uncomment and supply the name you want exposed in DNS.
- if you wanted the machine to be known on your local network as ‘superman’, the line would look like
send host-name 'superman';
- if you wanted the machine to be known on your local network as ‘superman’, the line would look like
- renew your dhcp lease to ‘push’ this change up to your dns server:
dhclient eth0
- note: replace
eth0
with your active interface if it is noteth0
- note: replace
That’s all there is to it! Go to another computer in your network and try ping superman
and it should resolve.
Notes
If you assign static IPs via your router you can also assign a machine name but this does not work for non-static, non-router assigned IP/machine name instances.