How to set domainname permonently on RHEL?

James Bourne jbourne at hardrock.org
Sat Nov 17 05:12:01 UTC 2007


On Fri, 16 Nov 2007, Daniel.Marchand at space.gc.ca wrote:

> I have a workaround to make it work on RedHat 4.
>
> I added this line to /etc/rc.local
>
> #--------------------------------
>
> ypdomainname mydomainname.com
>
> #--------------------------------

If you want to set the ypdomainname read the kernel docs for sysctl as the
sysctl interface has a means to set ypdomainname.

So following that and using /etc/sysctl.conf you can set kernel.domainname
to have it permanently set on boot:

rio:-bash$ ypdomainname
(none)
rio:-bash$ sysctl kernel.domainname
kernel.domainname = (none)
rio:-bash$ sudo sysctl -w kernel.domainname=foobar.org
kernel.domainname = foobar.org
rio:-bash$ sysctl kernel.domainname
kernel.domainname = foobar.org
rio:-bash$ ypdomainname 
foobar.org

Under RHEL/Centos/FC set the DNS domain in /etc/sysconfig/network, add the
line

HOSTNAME=host.my.domain

>From /etc/rc.d/rc.sysinit this will set the FQDN via the hostname command
which also sets the hosts "domainname".

For DNS check that domain is set in /etc/resolv.conf to ensure you can
resolve hosts within your domain.  If you need to search other zones set
the search option.  See the resolver(5) man page for more info on that.

Regards
James

-- 
James Bourne                  | Email:            jbourne at hardrock.org
UNIX Systems Administration   | WWW:           http://www.hardrock.org
Custom UNIX Programming       | Linux:  The choice of a GNU generation
----------------------------------------------------------------------
"All you need's  an occasional kick in  the philosophy." Frank Herbert
Need an inexpensive domain alternative?  http://fastforwarddomains.com




More information about the redhat-sysadmin-list mailing list