Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I resolve 'Could not resolve host' error in Kali Linux after installation?

"I’ve installed Kali Linux on a virtual machine (using VirtualBox/VMware) and I’m having a problem with my internet connection. When I try to use commands like apt update or ping google.com, I get the error:

makefile
ping: google.com: Temporary failure in name resolution
or
E: Could not resolve ‘deb.debian.org’
I checked the network configuration with the command:
cat /etc/resolv.conf
My resolv.conf file appears empty or does not contain the correct DNS address.

What I’ve tried so far:
I set the DNS manually using:
bash
Copy code
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
I restarted the network service:
bash
Copy code
sudo systemctl restart networking
But the problem persists after a reboot. How can I permanently resolve this DNS issue in Kali Linux?"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The /etc/resolv.conf file does not have a valid DNS or is overwritten after reboot.

Quick fix:
Add DNS manually:

bash
Copy code
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
echo "nameserver 8.8.4.4" | sudo tee -a /etc/resolv.conf
Block further changes:

bash
Copy code
sudo chattr +i /etc/resolv.conf
Restart the network service:

bash
Copy code
sudo systemctl restart networking
Check the connection:

bash
Copy code
ping google.com
sudo apt update
Note:
If you use NetworkManager, configure DNS directly with:

bash
Copy code
sudo nmcli con mod "Wired connection 1" ipv4.dns "8.8.8.8 8.8.4.4"
sudo nmcli con up "Wired connection 1"

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading