When connecting to external devices via their DNS addresses in the UMH, you might encounter errors like:
level=error msg="Failed to connect to sql_raw: lookup myserverlocation.com on 10.43.0.10:53: no such host" @service=benthos label=sql_input path=root.inputThis error indicates that your custom DNS server was not properly detected by the UMH instance. This can happen if the DNS settings were not propagated via DHCP when setting up the operating system behind the UMH instance.
To resolve this issue, follow these steps to configure your DNS servers:
Steps to Configure DNS Servers
1. Update /etc/resolv.conf
SSH into your UMH instance and edit the /etc/resolv.conf file:
sudo nano /etc/resolv.confAdd or modify the nameserver entries to include your preferred DNS servers:
nameserver 100.64.0.2
nameserver 1.1.1.1
nameserver 8.8.8.8Note: Replace100.64.0.2,1.1.1.1, and8.8.8.8with the IP addresses of your custom DNS servers.
Save and close the file.
2. Restart CoreDNS Pods
CoreDNS, the DNS server running within your Kubernetes cluster, should automatically load the updated /etc/resolv.conf. However, to ensure it picks up the changes, restart the CoreDNS pods:
sudo $(which kubectl) --kubeconfig /etc/rancher/k3s/k3s.yaml
-n kube-system delete pods -l k8s-app=kube-dnsThis command deletes the existing CoreDNS pods, and Kubernetes will automatically recreate them with the updated configuration.
Edit CoreDNS ConfigMap (Optional)
If restarting CoreDNS doesn't resolve your DNS issues, you can manually edit the CoreDNS ConfigMap to specify your custom DNS servers directly.
Step 1: Edit the ConfigMap
sudo $(which kubectl) --kubeconfig /etc/rancher/k3s/k3s.yaml
-n kube-system edit configmap corednsStep 2: Modify the forward Section
In the ConfigMap editor, locate the forward plugin section and modify it to include your DNS servers. Here are some examples:
Use a Single External DNS Server:
forward . 1.1.1.1
Use External DNS and /etc/resolv.conf:
forward . 1.1.1.1 /etc/resolv.confUse Multiple DNS Servers with Round-Robin and Failover:
forward . 1.1.1.1 8.8.8.8Enable Detailed Logging (Optional): Add the log directive to enable verbose logging:
logStep 3: Save and Exit
After making the necessary changes, save and exit the editor.
Step 4: Restart CoreDNS Pods
sudo $(which kubectl) --kubeconfig /etc/rancher/k3s/k3s.yaml
-n kube-system delete pods -l k8s-app=kube-dnsConclusion
By following these steps, you should be able to configure your UMH instance to use your custom DNS servers, ensuring proper domain resolution for your applications both within the cluster and in your external network environment.