This blog will walk you through configuring BIND as a DNS server, manually verifying the setup, and using the nmstate operator to apply DNS configurations in a running OpenShift cluster.
Section 1: Configure BIND
- Install BIND Packages
yum install bind bind-utils
- Edit BIND Configuration
Modify
/etc/named.conf
to specify listening IP addresses and allow queries:
listen-on port 53 { 127.0.0.1; 192.168.0.1; };
allow-query { localhost; 192.168.0.0/16; };
allow-recursion { localhost; 192.168.0.0/16; };
- Configure Forwarders (Optional) If needed, add forwarders to delegate DNS queries:
forwarders { 8.8.8.8; 8.8.4.4; };
forward only;
- Verify Configuration
named-checkconf
- Start BIND and Enable DNS Traffic
firewall-cmd --permanent --add-service=dns
firewall-cmd --reload
systemctl enable --now named
Section 2: Manual Verification
- Set DNS Temporarily on OpenShift Nodes
To preserve changes in
/etc/resolv.conf
for testing, use:
chattr +i /etc/resolv.conf
Verify the effect of chattr
:
lsattr /etc/resolv.conf
Once DNS functionality is confirmed, revert:
chattr -i /etc/resolv.conf
- Test DNS Resolution
dig @localhost www.example.org
Section 3: Using nmstate Operator to Configure in a Running Cluster
Install nmstate Operator
Apply the nmstate configuration to specify the DNS server in OpenShift.Apply DNS Configuration
Use the following configuration for the DNS resolver:
apiVersion: nmstate.io/v1
kind: NodeNetworkConfigurationPolicy
metadata:
name: worker1-dns
spec:
nodeSelector:
kubernetes.io/hostname: worker1
desiredState:
dns-resolver:
config:
search:
- example.com
server:
- 192.168.0.10
- Validate
oc get nncp
Top comments (0)