Setting domain name/nis domainname permanently

Issues related to configuring your network
Post Reply
Jensener
Posts: 4
Joined: 2014/07/09 09:01:48

Setting domain name/nis domainname permanently

Post by Jensener » 2014/07/09 10:08:09

Setting the domain name using the command "domainname example.com" or the NIS domain name using "nisdomainname example.com" works fine but how do I set them permanently? Entering DOMAINNAME=example.com or NISDOMAIN=example.com in /etc/sysconfig/network (as it was in CentOS 6) has no effect.

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Setting domain name/nis domainname permanently

Post by TrevorH » 2014/07/09 10:31:20

NIS is a complete mystery to me but how does this relate to the hostname? Perhaps hostnamectl is what you're after on CentOS 7?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Jensener
Posts: 4
Joined: 2014/07/09 09:01:48

Re: Setting domain name/nis domainname permanently

Post by Jensener » 2014/07/09 10:42:05

"hostnamectl" lets me set the hostname of the client but neither the domain name nor the NIS domainname...

thanhtaolao
Posts: 1
Joined: 2014/07/10 01:49:01

Re: Setting domain name/nis domainname permanently

Post by thanhtaolao » 2014/07/10 01:50:32

try to edit file: /etc/hostname

add the name of your host, ex: cent7

Jensener
Posts: 4
Joined: 2014/07/09 09:01:48

Re: Setting domain name/nis domainname permanently

Post by Jensener » 2014/07/10 07:41:09

thanhtaolao wrote:try to edit file: /etc/hostname
add the name of your host, ex: cent7
Doesn't work. The command "domainname" still gives me "(none)" and the output of "ypdomainname" is still "ypdomainname: Local domain name not set"

Jensener
Posts: 4
Joined: 2014/07/09 09:01:48

Re: Setting domain name/nis domainname permanently

Post by Jensener » 2014/07/10 09:25:09

I solved it by entering the following into /etc/sysctl.conf:

kernel.domainname=example.com

It sets the domain name and NIS domain name permanently.

mike.scchen
Posts: 3
Joined: 2014/10/24 10:42:20
Location: Taipei, Taiwan

Re: Setting domain name/nis domainname permanently

Post by mike.scchen » 2014/10/24 11:16:14

I've just found that the service "rhel-domainname" reads /etc/sysconfig/network for the NISDOMAIN line, but is NOT enabled.
But there's a bug in the .service file that will stop the system from booting if enabled:
https://admin.fedoraproject.org/updates ... .51-2.fc20

So, add the line:
DefaultDependencies=no
in the [Unit] section of /usr/lib/systemd/system/rhel-domainname.service
and then simply:
systemctl enable rhel-domainname
will do the trick and make it work as before.

The steps above has been tested with initscripts-9.49.17-1.el7_0.1 on CentOS 7.

Post Reply