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.

How can I set the domain name in GNU/Linux?, I am using Crunchbang and I need to set the domain name for my LAN network.

EDIT: Let me talk more about my problem: I need to configure a LAN network for three or four PCs with GNU/Linux(college project):

PC1: acting as server  -- hostname = "server"     -- GNU/Linux Debian Squeeze
PC2: client 1          -- hostname = "crunchbang" -- GNU/Linux Crunchbang
PC3: client 2          -- hostname = "acer"       -- GNU/Linux Debian Squeeze

Crunchbang is based on debian then "I think" there is no much difference.

I am guiding me with this document and there says that the domain name for all hosts in the network must be the same.

The OS in PC1 and PC3 are fresh installations, Crunchbang is the OS what my friend have in his laptop.

When I installed debian in PC1 and PC3 I set the domain name and the host name but now only the last is present.

share|improve this question
add comment

4 Answers

Step1: Change the New Values in the Host file

[root@erp ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
192.168.0.1        erp.myappsdba.com  erp
[root@erp ~]#

Step2: Change the New Values in the network file

[root@erp ~]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=erp.myappsdba.com
GATEWAY=192.168.0.3

Step3: Change the New Values in the sysctl.conf and resolv.conf files

[root@erp ~]## cat /etc/sysctl.conf
kernel.hostname=erp.myappsdba.com
kernel.domainname=myappsdba.com

[root@erp etc]# cat /etc/resolv.conf
search myappsdba.com
nameserver 192.168.0.7
nameserver 192.168.0.2
option attemts : 5
option timeout :15
[root@erp etc]#

Step4:Ping the Host Name or Changed IP Address.

[root@erp etc]# ping myappsdba.com
PING myappsdba.com (192.168.0.1) 56(84) bytes of data.
64 bytes from fortedc.myappsdba.com (192.168.0.1): icmp_seq=1 ttl=128 time=1.06 ms

Step5:Restart the Network or Reboot the system for effecting the changes

[root@erp ~]# init 6     

or

[root@erp ~]# service network restart 
share|improve this answer
    
+1 I don't use Crunchbang anymore so I can't verify you answer. Thanks anyway. –  rendon Jul 23 '13 at 22:04
add comment

edit /etc/hostname

<hostname>.<domainname>

Then edit your /etc/hosts

  127.0.0.1 <hostname>.<domainname> <hostname>
share|improve this answer
    
Nope! That don't work! –  rendon Nov 30 '11 at 4:27
    
Restart the computer? If is that, yes, I have restarted my computer. –  rendon Nov 30 '11 at 4:40
add comment

You really need to qualify what you mean by "set the domain name" - there are at least three completely different interpretations of "domain" that might apply.

  1. You want to set the Windows Domain the system will use for SMB networking.

    I don't know offhand how to do this, but it would probably involve editing your Samba configuration; http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/domain-member.html#ads-member would probably be a good place to start looking

  2. You want to set the default DNS name (lookup)

    llua's answer above sets the domain component of the hostname, but if you want ping myhost to find myhost in the local DNS domain, let's say it is accounting.example.com, you need a search line in /etc/resolv.conf, for example:

    search accounting.example.com
    

    On some systems, /etc/resolv.conf is managed by the resolvconf system (this is true on my Ubuntu system, not sure about Debian in general or Crunchbang in particular) - if /etc/resolv.conf is a symlink to /etc/resolvconf/run/resolv.conf then you should probably be editing /etc/network/interfaces, which should contain a stanza like this:

    iface eth0 inet static
               address 192.0.2.3
               netmask 255.255.255.0
               gateway 192.0.2.1
               dns-nameservers 192.0.2.1 198.51.100.1
               dns-search accounting.example.com example.com
    

    If you use DHCP to set up the local networking configuration, the DHCP daemon should set up both the local hostname and the DNS resolver search path automatically - you may find that is a better solution than either llua's or mine, at least if there is a local DHCP server and it is properly configured to provide DNS search information.

  3. You want to set the NIS (YP) domain name, used for passwd/group/hosts/etc. lookups on some systems with NFS file sharing set up.

    You might do this by editing /etc/domainname, and/or immediately (but temporarily) with the domainname NISNAME command. Note that the NIS domain name need not be the same as the DNS domain name (indeed some recommend that it not be), although at least in some cases the NIS domain name will be set automatically to the domain component of the hostname if not otherwise configured.

share|improve this answer
    
I have added more info in the original question. –  rendon Nov 30 '11 at 16:38
add comment

Try making changes to either

1)

/etc/rc.sysinit or /etc/sysconfig/network (if it supports sysconfig style of configuration);

2) Run network-admin as root and make the changes via GUI network-admin

&

confirm with /bin/hostname command

3) eitherways, making changes to /etc/hostname with format and then restart the network service should help.

share|improve this answer
    
I would add to the mix the /etc/resolve.conf, since all of those files change are recommended. I think that part one of you answer is for Redhat based only. –  Hanan N. Nov 30 '11 at 7:30
add comment

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.