howto lock DNS number in /etc/resolv.conf

Tom H tomh0665 at gmail.com
Sun Aug 21 14:45:10 UTC 2011


On Sat, Aug 20, 2011 at 9:00 PM, Tom Horsley <horsley1953 at gmail.com> wrote:
> On Sat, 20 Aug 2011 20:36:55 -0400 james tate wrote:
>
>> How can I lock down DNS nameserver in /etc/resolv.conf , every time I
>> reboot the DNS is changed ?
>
> Two ways: Edit the /etc/sysconfig/network-scripts/ifcfg-<whatever>
> script for the interface associated with the router providing the
> bad info and add the line:
>
> PEERDNS=no
>
> You might have to reboot a couple of times after that to get the
> network properly shutdown and restarted with the PEERDNS=no
> line in place.
>
> After the reboots, it should be safe to manually edit /etc/resolv.conf
> and the contents should remain undisturbed from that point on.
>
> P.S. This only works for redhat based distros.

A more generic way is to edit "/etc/dhcp/dhclient.conf" not to request
DNS server settings from the DHCP server with a "supercede" statement.


More information about the users mailing list