/etc/resolv.conf often automatically rewrite solutions in Linux

Source: Internet
Author: User

Previously encountered cases (DNS server caught incorrectly, and will be overwritten!) )

Ubuntu 6.10 (Edgy) only catches the ADSL Modem DHCP server IP when dialing via PPP.
Ubuntu 7.04 (feisty) The hateful Network-manager program will periodically catch the ADSL Modem DHCP server IP.

When the Guest OS in VMWare acquires IP on a NAT network, only the NAT DHCP server IP is caught.
So a lot of people jump out and ask a question: "How to avoid resolv.conf being modified, rewritten and overwritten, and so on?" “

However, for *nix such a flexible system, there are many solutions, we all see, which rough, which elegant!

Solution One: Modify the/sbin/dhclient-script, comment out the place to operate the resolv.conf.

The code is as follows Copy Code

Linux:

Comment out the call to make_resolv_conf this function!

Freebsd:

Comment out the line where > resolv.conf is located!

solution two: forced to modify the resolv.conf file flag, set to not be changed.

The code is as follows Copy Code

Linux:www.111cn.net

Chattr +i/etc/resolv.conf

Freebsd:

Chflags schg/etc/resolv.conf

Solution III: Change the DHCP client configuration file, in a specific link to append our settings.

The code is as follows Copy Code

Linux (Ubuntu Dist.) :

Add the following setting to the/etc/dhcp3/dhclient.conf: prepend domain-name-servers <ip1> <ip2>;

Freebsd:

Add the following setting to the/etc/dhclient.conf: prepend domain-name-servers <ip1> <ip2>;

In my opinion: the solution one belongs to the rough, the solution two belongs to the violence, the solution three is the good method!

Solution three does not change the system framework, or the original execution process. We are just in the default prepend link, adding more prepend content so that the DHCP Client
After you get the DNS server information, append the configuration we need to the front.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.