[Indimail-support] Neat trick to bypass /etc/resolv.conf, use your own custom resolv.conf to use dn
Brought to you by:
mbhangui
|
From: Manvendra B. <mbh...@gm...> - 2017-05-10 19:24:58
|
I had a situation where I am running dnscache on local laptop running
indimail. However my resolv.conf would get updated by NetworkManager
or by vpn client. There are solutions to modify have NetworkManager
scripts / dhclient scripts / interface startup scripts to have
nameserver as 127.0.0.1, but I found those solutions different for
different distros. Here is a neat solution using unshare command from
util-linux. This command is available on centos, rhel, debian, ubuntu.
This is how you do it
1. Modify svscanboot to call unshare --mount e.g.
exec unshare --mount env - PATH=$PATH \
SCANINTERVAL=$SCANINTERVAL SCANLOG="" \
STATUSFILE=$STATUSFILE \
/usr/sbin/svscan $SERVICEDIR
2. Modifed svscan to execute the following command before calling supervise
/usr/bin/mount --bind /etc/indimail/resolv.conf /etc/resolv.conf
3. in /etc/indimail/control have the following entry
nameserver 127.0.0.1
Now all services started by svscan will transparently use
/etc/indimail/resolv.conf as /etc/resolv.conf
There are many other things you can do with unshare. You can use a
totally different hostname, domain name on per process basis
you can find the mount point in /proc/$pid/mountinfo where pid is the
process id of svscan process.
Read more about unshare at
http://blog.endpoint.com/2012/01/linux-unshare-m-for-per-process-private.html
--
Regards Manvendra - http://www.indimail.org
GPG Pub Key
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xC7CBC760014D250C
|