Skip to content

Instantly share code, notes, and snippets.

@MahdadGhasemian
Last active March 5, 2026 13:28
Show Gist options
  • Select an option

  • Save MahdadGhasemian/ca198616b30f9f0468ddc64ba2169dfb to your computer and use it in GitHub Desktop.

Select an option

Save MahdadGhasemian/ca198616b30f9f0468ddc64ba2169dfb to your computer and use it in GitHub Desktop.
A handwritten reference on Iranian DNS hosts, alongside practical DNS notes for Ubuntu, Kubernetes, and Kubespray, including troubleshooting tips.

Iranian DNS servers list (domestic)

DNS Server Status
217.218.155.155 OK
217.218.127.127 OK
46.209.209.209 FAILED
185.161.112.33 OK
185.161.112.34 FAILED
185.51.200.10 FAILED
185.231.182.126 FAILED
46.224.1.42 FAILED
194.225.62.80 OK
213.176.123.5 OK
91.99.101.12 FAILED
185.187.84.15 FAILED
37.156.145.229 FAILED
185.97.117.187 FAILED
185.113.59.253 FAILED
80.191.40.41 FAILED
194.225.73.141 FAILED
91.245.229.1 OK
185.51.200.50 FAILED
37.156.145.21 FAILED
2.189.44.44 OK
2.188.21.131 FAILED
2.188.21.132 FAILED
81.91.144.116 FAILED
2.188.21.130 FAILED
92.119.56.162 FAILED
5.200.200.200 OK

Commands

Checking the current DNS configuration:

# Display the current DNS configuration and status of the systemd-resolved service
resolvectl status

Flushing the DNS cache:

resolvectl flush-caches
# Or
sudo systemd-resolve --flush-caches

Applying changes to the DNS configuration:

sudo netplan apply

Restarting the DNS resolver services to apply changes

sudo systemctl restart systemd-resolved
sudo systemctl restart NetworkManager

Testing DNS resolution for a specific domain using a specific DNS server:

dig @<DNS_SERVER_IP> <DOMAIN_TO_TEST> +short
# Or simply
dig <DOMAIN_TO_TEST> +short

Ensure Traffic goes out

ip route get DNS-SERVER-IP

Change DNS servers on AlmaLinux

  1. List active connections
nmcli con show
  1. Set DNS servers for a connection
sudo nmcli con mod "ens192" \
  ipv4.ignore-auto-dns yes \
  ipv4.dns "DNS-SERVER-IP-1 DNS-SERVER-IP-2"

sudo nmcli con mod "ens192" \
  ipv4.ignore-auto-dns yes \
  ipv4.dns "DNS-SERVER-IP-1 DNS-SERVER-IP-2"
  1. Restart the connection
sudo nmcli con down "ens192"
sudo nmcli con up "ens192"
  1. Verify
resolvectl status
cat /etc/resolv.conf

Kubernetes Notes (Kubespray)

Kubectl checks

Check What CoreDNS Is Forwarding To

kubectl -n kube-system get configmap coredns -o yaml

It results in something like this:

apiVersion: v1
data:
  Corefile: |
    .:53 {
        errors {
        }
        health {
            lameduck 5s
        }
        ready
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        forward . /etc/resolv.conf {
          prefer_udp
          max_concurrent 1000
        }
        cache 30

        loop
        reload
        loadbalance
    }
kind: ConfigMap

The forward . /etc/resolv.conf line indicates that CoreDNS is forwarding DNS queries to the DNS servers specified in the /etc/resolv.conf file on the nodes. You can check the contents of this file to see which DNS servers are being used for forwarding:

cat /etc/resolv.conf

Check On Node1

  1. Check the contents of /etc/resolv.conf to see which DNS servers are being used for forwarding:
cat /etc/resolv.conf

It results in something like this:

# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad
search default.svc.cluster.local svc.cluster.local
  1. Check the current DNS configuration and status of the systemd-resolved service:
resolvectl status

It results in something like this:

Global
         Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
  resolv.conf mode: stub
Current DNS Server: 169.254.25.10
Global
         Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
  resolv.conf mode: stub
Current DNS Server: 169.254.25.10
Global
         Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
  resolv.conf mode: stub
Current DNS Server: 169.254.25.10
       DNS Servers: 169.254.25.10
        DNS Domain: default.svc.cluster.local svc.cluster.local
...

Resolve loop dns issue on kubernetes

Loop DNS Issue in Kubernetes occurs when the CoreDNS pods are configured to forward DNS queries to themselves, creating a loop that prevents DNS resolution from working correctly. This can lead to CoreDNS pods crashing and entering a CrashLoopBackOff state.

You likely have this chain:

Pod
  ↓
NodeLocalDNS (169.254.20.10)
  ↓
CoreDNS
  ↓
/etc/resolv.conf
  ↓
wrong upstream (loopback or blocked DNS)

Or worse:

CoreDNS → /etc/resolv.conf → 127.0.0.53 → systemd-resolved → back to CoreDNS

That creates a loop → CoreDNS exits → CrashLoopBackOff.

If you encounter a DNS resolution loop in Kubernetes, it typically means that the CoreDNS pods are trying to resolve DNS queries through themselves, which can lead to a loop. To resolve this issue, you can follow these steps:

Kubespray project

  1. Edit the all.yml file in the group_vars/all directory of your Kubespray inventory:
kubespray/inventory/k8scluster/group_vars/all/all.yml
  1. Update the upstream_dns_servers variable to include the IP addresses of reliable upstream DNS servers (e.g., Google's public DNS servers or your preferred DNS servers):
## Upstream dns servers
# upstream_dns_servers:
#   - 8.8.8.8
#   - 8.8.4.4
upstream_dns_servers:
  - 217.218.155.155
  - 217.218.127.127
  1. Run the Ansible playbook to apply the changes to your Kubernetes cluster:
ansible-playbook -i inventory/k8scluster/inventory.ini cluster.yml --become --become-user=root --user=root --tags coredns,dns
217.218.155.155
217.218.127.127
46.209.209.209
185.161.112.33
185.161.112.34
185.51.200.10
185.231.182.126
46.224.1.42
194.225.62.80
213.176.123.5
91.99.101.12
185.187.84.15
37.156.145.229
185.97.117.187
185.113.59.253
80.191.40.41
194.225.73.141
91.245.229.1
185.51.200.50
37.156.145.21
2.189.44.44
2.188.21.131
2.188.21.132
81.91.144.116
2.188.21.130
92.119.56.162
5.200.200.200
77.104.104.104
DNS Health Result - 2026-03-05 16:16:51
--------------------------------------
| DNS Server | Status |
| --------------- | ------ |
| 217.218.155.155 | OK |
| 217.218.127.127 | OK |
| 46.209.209.209 | FAILED |
| 185.161.112.33 | OK |
| 185.161.112.34 | FAILED |
| 185.51.200.10 | FAILED |
| 185.231.182.126 | FAILED |
| 46.224.1.42 | FAILED |
| 194.225.62.80 | OK |
| 213.176.123.5 | OK |
| 91.99.101.12 | FAILED |
| 185.187.84.15 | FAILED |
| 37.156.145.229 | FAILED |
| 185.97.117.187 | FAILED |
| 185.113.59.253 | FAILED |
| 80.191.40.41 | FAILED |
| 194.225.73.141 | FAILED |
| 91.245.229.1 | OK |
| 185.51.200.50 | FAILED |
| 37.156.145.21 | FAILED |
| 2.189.44.44 | OK |
| 2.188.21.131 | FAILED |
| 2.188.21.132 | FAILED |
| 81.91.144.116 | FAILED |
| 2.188.21.130 | FAILED |
| 92.119.56.162 | FAILED |
| 5.200.200.200 | OK |
#!/bin/bash
DOMAIN_TO_TEST="digikala.com"
count=0
output_file="dns_health_check_results.txt"
# Date and time of the health check
echo "DNS Health Result - $(date '+%4Y-%2m-%2d %2H:%2M:%2S')" > "$output_file"
echo "--------------------------------------" >> "$output_file"
echo "" >> "$output_file"
# Adding Markdown table header to the output file
echo "| DNS Server | Status |" >> "$output_file"
echo "| --------------- | ------ |" >> "$output_file"
while IFS= read -r ip; do
((count++))
# Starting the health check for the current DNS server
printf "%3d Checking DNS Server: %-15s ... " "$count" "$ip"
# Performing the DNS query and capturing the result
result=$(dig @"$ip" "$DOMAIN_TO_TEST" +short +time=2 +tries=1 2>/dev/null | grep -v "^;" | grep -v "^$")
# Checking if the result is not empty, which indicates a successful DNS resolution
if [[ -n "$result" ]]; then
echo "OK -> $result"
printf "| %-15s | %-6s |\n" "$ip" "OK" >> "$output_file"
else
echo "FAILED"
printf "| %-15s | %-6s |\n" "$ip" "FAILED" >> "$output_file"
fi
done < dns-server-ip-list.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment