Re: Neat trick to bypass /etc/resolv.conf and use your own resolv.conf for dnscache

Charles Cazabon <[email protected]> Thu, 11 May 2017 13:36:37 -0600
Newsgroups gmane.mail.qmail.general
Message-ID <[email protected]>
Manvendra Bhangui <[email protected]> wrote:
> >
> > Looks like overkill.  Why not just make resolv.conf immutable?
> 
> That does not work for me. The unshare command 

I'm aware of how namespaces work, and how unshare provide commandline access
to some of their features, thanks.

> $ ls -l /etc/resolv.conf /var/run/NetworkManager/resolv.conf
> lrwxrwxrwx. 1 root root 35 May 11 08:37 /etc/resolv.conf ->
> /var/run/NetworkManager/resolv.conf
> -rw-r--r--. 1 root root 97 May 11 08:37 /var/run/NetworkManager/resolv.conf
> 
> $ chattr +i /var/run/NetworkManager/resolv.conf
> chattr: Inappropriate ioctl for device while reading flags on
> /var/run/NetworkManager/resolv.conf

That's not quite what I meant.  Didn't you say you wanted to use resolv.conf
(system-wide) pointing to your own dnscache resolver?

I meant, after removing /etc/resolv.conf (if it's a symlink) and replacing it
with a file pointing to your dnscache, make /etc/resolv.conf immutable, so
that NetworkManager or other completely-retarded programs that don't let you
opt out of their "helpful" replacing of /etc/resolv.conf can't screw it up on
you.

That has always worked for me.  No namespaces needed.  If you want to have
*different* resolv.conf contents for different programs on your system, then
yes, you'll need to use namespaces or overlay filesystems or something to
accomplish it, if the programs you want to configure can't have their
name-resolution methods configured separately.

Charles
-- 
--------------------------------------------------------------------------
Charles Cazabon
GPL'ed software available at:                  http://pyropus.ca/software/
Read http://pyropus.ca/personal/writings/12-steps-to-qmail-list-bliss.html
--------------------------------------------------------------------------