Change the DNS in Linux
1. Open the /etc/resolv.conf
file
sudo nano /etc/resolv.conf
2. Add/modify the lines and save (CTRL + S / CTRL + X
):
nameserver 192.168.1.9 # DNS 1
nameserver 192.168.1.8 # DNS 2
3. Make /etc/resolv.conf
immutable: This will prevent any other services from modifying it. Use the following command:
sudo chattr +i /etc/resolv.conf
4. Test your DNS configuration: After making these changes, test if DNS resolution works using:
dig google.com
No Comments