I'm on a Kubuntu 11.10 and I'm having trouble setting a hostname on the network.

I already tried changing send host-name "myhostname" in /etc/dhcp/dhclient.conf or /etc/dhcp3/dhclient.conf with a networking restart after that (even a reboot).

My hostname is still new-host-4 or new-host-5. I assume it's the DHCP server who gave me these names.

I also know that the servers allows these request since iPhones, Macs can set their hostnames and the hostname I ask is not in use.

Any idea what to do ?

  • See this askubuntu Q&A, it covers all the bases: askubuntu.com/questions/87665/…
    – slm
    Commented May 15, 2013 at 13:03
  • Thanks but that's not my probem : I don't have my hostname on the network. Commented May 16, 2013 at 7:39
  • Your question is confusing then. Are you saying that your hostname isn't getting set correctly on the actual host or that it isn't showing up correctly to other systems on your network after you send it to the DHCP server?
    – slm
    Commented May 16, 2013 at 8:23
  • If it wasn't clear sorry, but it's correctly set on the actual host but not on the network. Commented May 16, 2013 at 8:54
  • Just because you can can send your desired hostname to the DHCP server doesn't mean that your hostname will show up on the network for others to use. The DHCP server has to be specially configured to relay that information you sent to it to another service/daemon called DNS which is responsible for resolving names to IP addresses. The DNS server is usually a program called bind on Linux/Unix. Do you control this DHCP server?
    – slm
    Commented May 16, 2013 at 8:58

5 Answers 5


Some routers only use the netbios hostname.

On Debian you can

sudo apt-get install samba

and if your /etc/hostname is set correctly this will show up in the network without a restart.

This works for RaspberryPi, BeagleboneBlack and as far as I can remember also with Ubuntu.

  • just installing samba? no need to setting it up?
    – dashesy
    Commented Mar 18, 2020 at 20:39
  • 1
    @dashesy as far as I remember, but I will have confirm?
    – skvery
    Commented Mar 27, 2020 at 12:44

You can change the hostname by editing the /etc/hostname file and you need to update the kernel parameter "kernel.hostname" to make it effective at instant

hostname command is an one more option

check here : http://linuxinternetworks.com/how-to-change-hostname-in-linux/

  • I'm have a local hostname but it's not visible on the network Commented May 15, 2013 at 12:32

OK then I understand what you're asking for now. You have control over a DHCP router/switch which is also responsible for DNS name resolving.

Take a look in the dhclient.conf man page. Specifically you'll need to add some additional lines to your /etc/dhcp/dhclient.conf file.

For starters you'll need to add this line:

send host-name 'your-hostname-here';

NOTE: The line has to include the trailing semicolon!

If you want to send a fully qualified domain name (fqdn) - myhost.mydomain.com instead of just myhost you need to add these lines too:

send fqdn.fqdn "myhost.mydomain.com.";
send fqdn.encoded on;
send fqdn.server-update off;
also request fqdn, dhcp6.fqdn;

You must use hostname command to edit your hostname.

hostname <newname>

/etc/host and /etc/hostname should contain the hostname, but not the FQDN.

But you do have the hostname tool that will let you view and set the hostname.

man hostname should give you more information.

Alternatively, the man pages online are available as well.

As you are not able to see the hostname on the network, there are a few options to have this available. An /etc/hosts file exists as one solution. If you have a static local IP address, this is simple to edit, and will remain valid.

You have the choice of having DHCP set names as well.

Alternatively, you can set up a NIS server.

The /etc/hosts is quicker as far as lookups go, as the file and authority is local to each machine. But depending on the number of machines, the updates can take some time, if things change.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .