# Custom resolv.conf location not working



## ranceh (May 13, 2022)

I am a dnsmasq user that had a setup working the way I want under 13.0-RELEASE.  Since upgrading to 13.0-RELEASE-p11 I have noticed a problem.

I have a resolvconf.conf file with a single line: resolv.conf=/etc/resolv.conf.dhcp

I have a real static /etc/resolv.conf file that tells the box to use itself for name resolution, and I also tell dnsmasq to use the custom /etc/resolv.conf.dhcp for upstream data.

This used to work correctly, but post upgrade to p11 the resolver is writing to resolv.conf instead of the alternate location requested in the config file.  This breaks a whole lot of things.

I didnt notice any changes to the resolv.conf process in the changelog, but then, I could easily have missed something.

How do I restore the desired behavior?  How do I tell the resolvconf creation tool not to touch resolv.conf and instead manage the alternate file?


----------



## gpw928 (May 14, 2022)

If your dhclient(8) is clobbering /etc/resolv.conf, you can populate it, and then make it immutable:
	
	



```
sudo chflags schg /etc/resolv.conf
```


----------



## Alain De Vos (May 14, 2022)

I have two lines in resolvconf.conf,

```
resolv_conf="/dev/null"
unbound_conf="/dev/null"
```
It prevents updating of /etc/resolv.conf


----------



## Phishfry (May 14, 2022)

Only one line in mine with DNSMasq installed.
/etc/resolvconf.conf

```
resolvconf=NO
```

/etc/rc.conf

```
resolv_enable="NO"
```

/usr/local/etc/dnsmasq.conf

```
domain-needed
bogus-priv
strict-order
no-resolv
interface=lagg0
interface=em1
listen-address=127.0.0.1,192.168.1.1,192.168.2.1
expand-hosts
server=1.1.1.1
server=8.8.4.4
local=/localdomain/
domain=localdomain
dhcp-authoritative
dhcp-range=set:em1,192.168.2.10,192.168.2.20,72h
dhcp-range=set:lagg0,192.168.1.100,192.168.1.140,72h
dhcp-option=em1,option:router,192.168.2.1
dhcp-option=lagg0,option:router,192.168.1.1
dhcp-option=option:dns-server,1.1.1.1,8.8.4.4
dhcp-option=option:domain-search,localdomain
#dhcp-option-force=option:domain-search,internal,localdomain
#log-dhcp
#log-queries
log-facility=/var/log/dnsmasq.log
dhcp-leasefile=/var/db/dnsmasq/dnsmasq.leases
cache-size=500
no-negcache
## conf ###
conf-dir="/usr/local/etc/dnsmasq.d"
# This fixes a security hole. see CERT Vulnerability VU#598349
dhcp-name-match=set:wpad-ignore,wpad
dhcp-ignore-names=tag:wpad-ignore
### Static IP ###
[SNIP]
```

Here is a real good method for network wide block lists.








						A Quick and Dirty DNS server using FreeBSD ( #100DaysToOffload Day 28)
					

In today's post i'm going to show you how to setup up something i should have done a long time ago. Knowing now how easy it could be. What is this thing? Setting up a in-home DHCP/DNS server. At first i wa...




					blog.marcg.pizza
				



`mkdir /usr/local/etc/dnsmasq.d`
`cd /usr/local/etc/dnsmasq.d`
`fetch https://github.com/notracking/hosts-blocklists/raw/master/dnsmasq/dnsmasq.blacklist.txt`


----------



## SirDice (May 17, 2022)

gpw928 said:


> If your dhclient(8) is clobbering /etc/resolv.conf, you can populate it, and then make it immutable:


A better way is to create a /etc/dhclient-enter-hooks:

```
add_new_resolv_conf() {
        # We don't want /etc/resolv.conf changed
        # So this is an empty function
        return 0
}
```
That will stop dhclient(8) from touching /etc/resolv.conf at all. While your solution will probably work, dhclient(8) is going to complain about the fact it can't write to that file.


----------

