Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I edit resolv.conf? [closed]

Tags:

linux

dns

I need to setup OpenDNS, but I can't edit resolv.conf

Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 127.0.1.1 search gateway.2wire.net 
like image 370
Ricky Wilson Avatar asked Oct 17 '13 16:10

Ricky Wilson


People also ask

How do I permanently edit resolv conf?

Make permanent changes in resolv.conf:Remove the preceding “#” and use the domain-name and domain-name-servers which you want. Save it. Now the DNS related changes will be permanent.

How does resolv conf get updated?

The “/etc/resolv. The contents of this file are added automatically by some networking application on your system. These entries are updated every time your system changes its location to a different networking domain.


1 Answers

Your system uses resolvconf, so the resolv.conf file is replaced by a symbolic link to /etc/resolvconf/run/resolv.conf and resolvconf dynamically generated the file. That's why DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

To properly update the information in the file, you can put the dns-* parameters in /etc/network/interfaces e.g.

auto eth0 iface eth0 inet static      address 33.33.13.10      netmask 255.255.255.0      gateway 33.33.13.1      dns-nameservers 33.33.13.1 12.34.56.78      dns-search example.com 

Then, you can update the dns-* info by

$ resolvconf -d eth0 $ resolvconf -a eth0 

Or you can do ifdown & ifup and resolvconf -d, -a will happen behind the scenes.

Note: sometimes I find resolvconf -u doesn't work. I don't know why

You should read man resolvconf. There's more information about all this.

TIP: if you want to update /etc/resolv.conf manually, you can remove the symlink and create /etc/resolv.conf by hand. This way, the file won't get updated from resolvconf ever.

    $ rm /etc/resolv.conf         ;# to remove the symlink     $ vi /etc/resolv.conf         ;# to create a regular file 
like image 116
Chawarong Songserm PMP Avatar answered Sep 21 '22 15:09

Chawarong Songserm PMP