Solved How to prevent or repair dhcp damage

I have looked about on several forums and have not found satisfying answers to this. So I will try here, since you folk seem to be more helpful than most non FreeBSD specific forum folks are. ;)

I have a couple of isp's that I use for different purposes. The problem is each insists on setting my /etc/resolv.conf to their server, and only to it, through dhcp at connection time. Sorry isp's, but those are not the servers I need to use, for reasons I will not elaborate on here. Every time I have to change connections, I have to manually reset resolv.conf. And sometimes this happens when the machines are unattended due to some failure, either mine or the ISP's. Then I get hosed but good by their setting.

First question is: Is there a good way to prevent dhcp from being so "helpful"? I have tried permission settings on both /etc and the file itself, but even when I set world read and nobody write or explore ( execute ), dhcp gets around me and changes it anyway. I have tried setting it immutable, but only fully system immutable seems to protect the file. But then when I DO want to change it it is a MAJOR UNDERTAKING of boot to single user mode, drop the immutable bit, and then continue the boot after resetting the bit to avoid anyone or anything from getting "helpful" again. Ceases to be entertaining after the first few times this has to be done. Any ideas to avoid the hassle while still getting the protection?

I have looked in vain for any documented way to make dhcp change its ways, but the couple of suggestions from non BSD sources, did not work. And I do not want to modify the dhcp process, again because it is potentially a problem during system maintenance, usually just when one is not needed or appreciated.

Second question is: I am able to work around this by overwriting what dhcp has given me, but this is also a manual undertaking at boot time. Therefore, says I, I shall enscript the overwrite to be automatically done at the end of the boot process. As of now /etc/rc.local is supported under the 13.x versions of FreeBSD, and I assume also the 14.x versions ( have not had a chance to test that yet ), but I get the strong feeling that this may be moving more and more in the direction of yet another rc.d script. So ... any feeling for how much longer rc.local might be viable and also whether I should be concentrating on rc.d style scripting instead? Note ... I am not averse to rc.d scripting, but rc.local is more familiar to me at this time.

Thanks for any insights you folk may have to offer!!!

QG
 


So as you have found /etc/resolv.conf is populated by the service resolvconf.

Use resolvconf.conf to disable it properly.
 
Following the second link, the one to "Custom resolv.conf not working", wherein SirDice suggested adding a file at /etc/dhclient-enter-hooks and making it do nothing but return, has solved this for me in a way that I particularly like. First off, it works. Second off, it keeps the damage from happening in the first place rather than fixing after the fact. Third off, it is absolutely elegant in its simplicity. Fourth off, it reminds me of the very thing I preach, but obviously missed in practice, to read everything before assuming anything. I stand humbled and corrected on that point. :) Well done, Sir, well done.

Gratefully,
QG
 
Did you try with supersede or ignore option in dhclient.conf?

supersede domain-name-servers 8.8.8.8, 8.8.4.4;
supersede domain-name "fugue.com rc.vix.com home.vix.com";

Check the example section in the manual:
 
I did try this, and it was a mixed bag. Usually worked, but not always. And I really don't know why it failed when it did or what led up to it.
According to the documentation I have in the man page, it should have. But who knows what lurks in the heart of a computer?
 
Back
Top