How to set domainname in RHEL 6 or CentOS 6 or NGE Linux 1.0 ?

In this post, we will check how to set/change domain name of our system in RHEL6 or CentOS6.

NGE Linux 1.0 is based on CentOS 6, hence everything based on Centos 6 is valid for NGELinux.

To set the domain name, we need to follow below four steps.

1. Enter domain name in /etc/sysconfig/network file.

[root@nglinux ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=nglinux
DOMAINNAME=ngelinux.com
[root@nglinux ~]# 

2. Now to make our system to search this domain, add “domain domainname” entry in /etc/resolv.conf.

[root@nglinux ~]# cat /etc/resolv.conf 
domain ngelinux.com
search ngelinux.com
nameserver 192.168.52.2
[root@nglinux ~]# 

3. Now the last thing is to make entry in /etc/hosts to make the FQDN entry of our system hostname.

[root@nglinux ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 nglinux
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.52.138  nglinux.ngelinux.com

Thats it !!

However there are two things to check:

4. Quick Check if hostname not defined in eth config file and existence of hostname file.

### hostname file exists on debian system & in RHEL7 onwards, so it needs to be verified.
### If it exists, enter the domainame into this file.
[root@nglinux ~]# ls -l /etc/hostname
ls: cannot access /etc/hostname: No such file or directory

### Another thing to verify: there should be no domain name defined in eth config file.
### If it is there, we need to change that as well.
[root@nglinux ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 
DEVICE="eth0"
BOOTPROTO="dhcp"
HWADDR="00:0C:29:5F:FC:F7"
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="a80b105c-75d7-497c-b34d-ad14e42a847b"
[root@nglinux ~]# 

I hope you liked the article.

Please do post your comments/feedback below.

0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
trackback
6 years ago

[…] We have already seen the tip of assigning the domain name here. […]