"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?"
>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"