# Custom resolv.conf location



## ranceh (Feb 14, 2022)

I'm running FreeBSD 13 as a home router, and I have pf rules, etc running and the network is almost configured the way that I want.

I'm running Dnsmasq for DHCP, DNS, and TFTP support and I'd like the gateway host to use Dnsmasq as the target for dns queries.

Dnsasq is configured to look at an alternate resolv.conf.dhcp file to get its upstream data.

I need to be able to two things:

1) not create the default /etc/resolv.conf
2) create instead the alternate /etc/resolv.conf.dhcp for use in Dnsmasq

I tried achieving this from /etc/dhclient-exit-hooks but that turns out to be a mistake because sometimes the resolv.conf file is not regenerated by the dhcp request if the data didn't change and that messed up things because I didn't know to test for that, and I broke things.  I knew there had to be something I was missing...

According to resolvconf.conf(), part of the solution seems to be to configure the dnsmasq subscriber, so I have this in my /etc/resolvconf.conf file:


```
dnsmasq_conf=/usr/local/etc/dnsmasq.conf
dnsmasq_resolv=/etc/resolv.conf.dhcp
```

The same man page also says that it might be possible to just set the path to the resolv.conf file with something like:


```
resolv.conf=/etc/resolv.conf.dhcp
```

I've never seen this idea of a resolv.conf subscriber before so can someone look over my shoulder and make sure this is right.

I have a hunch that this only solves part of my problem.  I suspect that this configuration does not stop the /etc/resolv.conf file from being created.

Most of the documentation I reviewed suggest that you can easily get resolvconf.conf to not create a resolv file, but I don't think that is what I want.

So the questions I have are:

1) Does this configuration successfully accomplish the goals, or is there something else I need to do?
2) What is that "something else"?


----------



## Phishfry (Feb 14, 2022)

ranceh said:


> I need to be able to two things:
> 
> 1) not create the default /etc/resolv.conf\


Create /etc/resolvconf.conf

```
resolvconf=NO
```

What resolvconf the service does is use /etc/resolv.conf to hold its settings.
With the above you control the contents of /etc/resolv.conf


----------



## Phishfry (Feb 14, 2022)

ranceh said:


> 2) create instead the alternate /etc/resolv.conf.dhcp for use in Dnsmasq


/usr/local/etc/dnsmasq.conf


```
## conf ###
conf-dir="/usr/local/etc/dnsmasq.d"
```

Like this:








						Setup dnsmasq on macOS for developer DNS
					

Setup dnsmasq on macOS for developer DNS. GitHub Gist: instantly share code, notes, and snippets.




					gist.github.com


----------

