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.