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 /usr/bin/unshare --mount env - \
PATH=$PATH \
/var/qmail/bin/svscan.sh
2. in /var/qmail/bin/svscan.sh
#!/bin/sh
/usr/bin/mount --bind /var/qmail/control/resolv.conf /etc/resolv.conf
exec /var/qmail/bin/svscan
3. in /var/qmail/control/resolv.conf
nameserver 127.0.0.1
Now all services started by svscan will transparently use
/var/qmail/control/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
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 /usr/bin/unshare --mount env - \
PATH=$PATH \
/var/qmail/bin/svscan.sh
2. in /var/qmail/bin/svscan.sh
#!/bin/sh
/usr/bin/mount --bind /var/qmail/control/resolv.conf /etc/resolv.conf
exec /var/qmail/bin/svscan
3. in /var/qmail/control/resolv.conf
nameserver 127.0.0.1
Now all services started by svscan will transparently use
/var/qmail/control/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