Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 ?

share|improve this question
    
See this askubuntu Q&A, it covers all the bases: askubuntu.com/questions/87665/… –  slm May 15 '13 at 13:03
    
Thanks but that's not my probem : I don't have my hostname on the network. –  Matthieu Riegler May 16 '13 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 May 16 '13 at 8:23
    
If it wasn't clear sorry, but it's correctly set on the actual host but not on the network. –  Matthieu Riegler May 16 '13 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 May 16 '13 at 8:58

4 Answers 4

You must use hostname command to edit your hostname.

hostname <newname>
share|improve this answer

/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.

share|improve this answer

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/

share|improve this answer
    
I'm have a local hostname but it's not visible on the network –  Matthieu Riegler May 15 '13 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;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.