How to change DNS on Linux?

This guide will show you how to edit, add, or remove the DNS settings on your Linux device.

Changing the DNS on your device can be helpful if you're looking to improve the connection quality and, in some cases - the speed.

1. Firstly, open the terminal with the CTRL + ALT + T combination and type in the following commands:

sudo rm -r /etc/resolv.conf

sudo nano /etc/resolv.conf

2. You will be asked for your root password after each command line, just type it in and press Enter. When the text editor opens, you will have to type in these lines:



3. Now close and save the file by clicking Ctrl + X and pressing Y.

4. After that, please type in one last command in the terminal and press Enter:

chattr +i /etc/resolv.conf

Screenshot_2021-07-29_at_12.10.24.png In case the chattr +i command does not work, try using the following command instead:

sudo chattr -f +i /etc/resolv.conf

5. Lastly, restart your Linux device.

Note: In case you have any questions or are experiencing any issues, please feel free to contact our 24/7 customer support team.


Return to top