Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I tried adding

dns-domain domain.com

to /etc/network/interfaces with no luck. When I run

hostname -d

I get an empty string

share|improve this question

4 Answers 4

Edit /etc/hostname and add your unqualified hostname:

boson

Edit /etc/hosts:

sudo vi /etc/hosts

Add an entry of your desired hostname by replacing boson.dev.local boson where boson.dev.local is the fully qualified hostname and boson is hostname.

127.0.1.1 boson.dev.local boson

Test your configuration by opening a terminal and enter the below commands:

  • hostname
    • This should output boson
  • hostname -f
    • This should output boson.dev.local

Hope this helps.

share|improve this answer
7  
It's important to note that the first domain in /etc/hosts should be your FQDN. I was stuck for quite some time :) –  Birla Nov 8 '13 at 20:35
    
Thanks @Birla, I was wondering why it wasn't working until I read your comment –  Erin Drummond Feb 19 at 20:36

The hostname command can be used to set the fully qualified hostname as well. Run it with the name passed as the first argument for that :

hostname www.example.com

This is only effective till a reboot, though. You can edit /etc/hostname for permanent changes.

For changing domainnames, the man page recommends the following :

Note, that only the super-user can change the names.

It is not possible to set the FQDN or the DNS domain name with the dnsdomainname command (see THE FQDN below).

The host name is usually set once at system startup in /etc/init.d/hostname.sh (normally by reading the contents of a file which contains the host name, e.g. /etc/hostname).

Usually you can set it in /etc/hosts

share|improve this answer

Put it in /etc/hostname.

For example, my machine is called hubble, so in my /etc/hostname I have:

ashton@hubble:~$ cat /etc/hostname
hubble.mydomain.blah.blah

You might need to reboot to get it to show up when you run uname though.

share|improve this answer

​I use domain names to bind my shared storage to my user group TIGERGROUP. This method allows for the domain name TIGERGROUP to be used as a CIFS share. Think of TIGERGROUP domain name as WORKGROUP domain in windows. If you have a server HOST name (myhost.com) then just add that to then end after the domain name.

example:

vi /etc/hosts
127.0.0.1       localhost
127.0.1.1       Aspire-Petra16.TIGERGROUP          #i.e. desktop running Petra Mint16
192.168.1.25    sharedstorage-1.local.TIGERGROUP.myhost-name.com   #shared storage media player

If I want Samba to also pickup the domain name then I also add it to the smb.conf I don't use samba at home so it is really unnecessary unless you want to be though.

example:

vi /etc/samba/smb.conf

#scrolling down the file for workgroup   

# workgroup = WORKGROUP              # pen out the old name with pound key
   **workgroup = TIGERGROUP**         # add the preferred domain name.

restart services (can be done from the GUI or use cmd line.)

sudo /etc/init.d/samba restart
sudo /etc/init.d/networking restart
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.