Install & Configure DNS on RHEL 7.x for local domain name resolution
Working in the lab again, getting a bunch of RHEL Servers to create a nice Satellite & Capsules farm but ran into a snag, name resolution.
[root@rhel77a Satellite-6.6.0 RHEL-7 x86_64]# satellite-installer --scenario satellite
Unable to resolve forward DNS for rhel77a
Output of 'hostname -f' does not seems to be valid FQDN
Make sure above command gives fully qualified domain name. At least one
dot must be present and underscores are not allowed. If needed, change the hostname permanently via the
'hostname' or 'hostnamectl set-hostname' command
and editing the appropriate configuration file.
(e.g. on Red Hat systems /etc/sysconfig/network,
on Debian based systems /etc/hostname).
If 'hostname -f' still returns an unexpected result, check /etc/hosts and put
the hostname entry in the correct order, for example:
1.2.3.4 hostname.example.com hostname
The fully qualified hostname must be the first entry on the line
Your system does not meet configuration criteria
[root@rhel77a Satellite-6.6.0 RHEL-7 x86_64]# hostnamectl set-hostname rhel77a.atomiclabs.com
[root@rhel77a Satellite-6.6.0 RHEL-7 x86_64]# hostname -f
rhel77a.atomiclabs.com
No worries, its time to make a few adjustments to permanently fix this issue. Its time for DNS, here goes the installation:
First install BIND and BIND UTILIS
# yum install bind bind-utils -y
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
Package 32:bind-utils-9.11.4-9.P2.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package bind.x86_64 32:9.11.4-9.P2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================
Package Arch Version Repository Size
========================================================================================================================
Installing:
bind x86_64 32:9.11.4-9.P2.el7 rhel-7-server-rpms 2.3 M
Transaction Summary
========================================================================================================================
Install 1 Package
Total download size: 2.3 M
Installed size: 5.4 M
Downloading packages:
No Presto metadata available for rhel-7-server-rpms
bind-9.11.4-9.P2.el7.x86_64.rpm | 2.3 MB 00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 32:bind-9.11.4-9.P2.el7.x86_64 1/1
Verifying : 32:bind-9.11.4-9.P2.el7.x86_64 1/1
Installed:
bind.x86_64 32:9.11.4-9.P2.el7
Complete!
Now lets configure the DNS Server to handle all these hosts that will be participating in the lab
[root@rhel77a /]# vi /etc/named.conf
Enable BIND to listen to all IP addresses in the labs network, in this case 192.168.0.1
options {
listen-on port 53 { 127.0.0.1; 192.168.0.29; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { localhost; 192.168.0.0/24; };
Now lets get the zones working, we will need the FORWARD and REVERSE zones configured, be sure to add this to the end of the /etc/named.conf file
zone "." IN {
type hint;
file "named.ca";
};
zone "atomiclabs.com" IN {
type master;
file "forward.atomiclabs";
allow-update { none; };
};
zone "0.168.192.in-addr.arpa" IN {
type master;
file "reverse.atomiclabs";
allow-update { none; };
};
Next I create a DNS zone file that was referenced in the /etc/named.conf file. Placing the file in /var/named directory and as “forward.atomiclabs”, here is what that file looks like:
; Athoritative data for atomiclabs.com zone
;
$TTL 1D
@ IN SOA rhel77a.atomiclabs.com. root.rhel77a.atomiclabs.com. (
2017031301 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
$ORIGIN atomiclabs.com.
atomiclabs.com. IN NS rhel77a.atomiclabs.com.
rhel77a IN A 192.168.0.29
rhel77b IN A 192.168.0.31
rhel75a IN A 192.168.0.24
rhel75influxdb IN A 192.168.0.19
atomiclabsrv01 IN A 192.168.0.21
And now for the reverse zone file similar to the forward also located in /var/named directory, only this time calling it “reverse.atomiclabs” (obviously duh). Here is what that file looks like in the lab now:
; Athoritative data for atomiclabs.com reverse zone
;
$TTL 1D
@ IN SOA rhel77a.atomiclabs.com. root.rhel77a.atomiclabs.com. (
2017031501 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS rhel77a.atomiclabs.com.
29 IN PTR rhel77a.atomiclabs.com.
21 IN PTR atomiclabsrv1.atomiclabs.com.
27 IN PTR rhel75lab.atomiclabs.com.
24 IN PTR rhel75a.atomiclabs.com.
19 IN PTR rhel75influxdb.atomiclabs.com.
31 IN PTR rhel77b.atomiclabs.com.
Final step is to turn on the service and try out the name resolution, I enabled and started the service as such
[root@rhel77a /]# systemctl enable named
Created symlink from /etc/systemd/system/multi-user.target.wants/named.service to /usr/lib/systemd/system/named.service.
[root@rhel77a /]# firewall-cmd --permanent --add-port=53/tcp
success
[root@rhel77a /]# firewall-cmd --permanent --add-port=53/udp
success
[root@rhel77a /]# firewall-cmd --reload
success
Also just to play it safe I validated each of the configurations to make sure they wouldnt bomb the service using named-checkconf utility like this;
[root@rhel77a /]# named-checkconf /etc/named.conf
[root@rhel77a /]# named-checkconf /var/named/forward.atomiclabs
[root@rhel77a /]# named-checkconf /var/named/reverse.atomiclabs
Final step is to start the DNS Service and make sure it is enabled for post reboot sequences
[root@rhel77a /]# systemctl start named
[root@rhel77a /]# systemctl enable named
Check out the reverse name lookup now
# nslookup 192.168.0.27
27.0.168.192.in-addr.arpa name = rhel75lab.atomiclabs.com.
# nslookup 192.168.0.19
19.0.168.192.in-addr.arpa name = rhel75influxdb.atomiclabs.com.
# nslookup 192.168.0.24
24.0.168.192.in-addr.arpa name = rhel75a.atomiclabs.com.
# nslookup 192.168.0.29
29.0.168.192.in-addr.arpa name = rhel77a.atomiclabs.com.
# nslookup 192.168.0.31
31.0.168.192.in-addr.arpa name = rhel77b.atomiclabs.com.
Check out the forward lookup now
# nslookup rhel75a.atomiclabs.com
Server: 192.168.0.29
Address: 192.168.0.29#53
Name: rhel75a.atomiclabs.com
Address: 192.168.0.24
# nslookup rhel75a
Server: 192.168.0.29
Address: 192.168.0.29#53
Name: rhel75a.atomiclabs.com
Address: 192.168.0.24
# nslookup rhel77b
Server: 192.168.0.29
Address: 192.168.0.29#53
Name: rhel77b.atomiclabs.com
Address: 192.168.0.31
# nslookup rhel75influxdb.atomiclabs.com
Server: 192.168.0.29
Address: 192.168.0.29#53
Name: rhel75influxdb.atomiclabs.com
Address: 192.168.0.19
# nslookup rhel75lab
Server: 192.168.0.29
Address: 192.168.0.29#53
Name: rhel75lab.atomiclabs.com
Address: 192.168.0.27
In summary everything is working both forward and reverse and now we can proceed with the installation of the original product that I started this journey with, RHEL SAT 6.6.0 🙂