Recently, I encountered another issue where/etc/resolv. conf will be rewritten on a regular basis. This is in FreeBSD!
In the LAN via NAT or PPPoE environment on the Internet, we have to specify the DNS server in resolv. conf, And the DNS server here is
Automatically obtained through the DHCP server. If not, manually add the DNS server provided by the ISP. But sometimes some "smart" Processes
The sequence will always jump out and make some small actions, change the settings we write ourselves, and round-robin. You can change it again, and it will be changed in a few minutes.
I have encountered some problems before (the DNS server is incorrect and will be changed !) :
- When Ubuntu 6.10 (Edgy) is dialing through ppp, only the IP address of the DHCP server of the ADSL Modem is caught.
- The hateful network-manager program of Ubuntu 7.04 (Feisty) regularly captures the IP address of the ADSL Modem DHCP server.
- When the Guest OS in VMWare obtains an IP address from a NAT network, only the IP address of the NAT DHCP server is caught.
As a result, many people jumped out and asked a question: "How to Avoid resolv. conf being modified, rewritten, and overwritten? "
However, for a flexible system like * NIX, there are also many solutions. One by one, we can see which one is rough and which one is elegant!
Solution 1: Modify/sbin/dhclient-script and comment out the operations on resolv. conf.
Linux:
Comment out all calls to the make_resolv_conf function!
FreeBSD:
Comment out the rows where> resolv. conf is located!
Solution 2: Force modify the flag of the resolv. conf file to make it unchangeable.
Linux:
Chattr + I/etc/resolv. conf
FreeBSD:
Chflags schg/etc/resolv. conf
Solution 3: change the configuration file of the DHCP Client and append our settings at specific links.
Linux (Ubuntu Dist .):
Add the following settings to/etc/dhcp3/dhclient. conf: prepend domain-name-servers <ip1>, <ip2>;
FreeBSD:
Add the following settings to/etc/dhclient. conf: prepend domain-name-servers <ip1>, <ip2>;
In my opinion, solution 1 is rough, solution 2 is violent, and solution 3 is a good solution!
Solution 3 does not change the system framework or the original execution process. We only add prepend content in the default prepend step to let the DHCP Client
After obtaining the DNS server information, append the required configurations to the front.