1

I modified /etc/resolv.conf to configure DNS for my VPN. Now I would like to modify it again but I can't. The operation is not permitted even if I use

sudo nano /etc/resolv.conf

I tried to start in recovery mode but I have the same problem. How can I restore this file?

wjandrea
  • 14,504
Anonymous
  • 113

1 Answers1

2

Just change permissions temporarily:

sudo chmod 744 /etc/resolv.conf

Add nameservers of your VPN provider by editing the file with text editor:

nameserver ip_of_nameserver_one
nameserver ip_of_nameserver_two

Save the file,then revert permissions.

sudo chmod 644 /etc/resolv.conf
sudo chattr +i /etc/resolv.conf

The last command will add immutable bit, so the file doesn't get overwritten. After you set immutable bit, even the root account will not be able to write to the file. If you wish to edit the file again latter on, and remove immutable bit, use this command:

sudo chattr -i /etc/resolv.conf
Zanna
  • 72,312
fugitive
  • 1,356
  • 8
  • 14