Is there any way I can specify a custom resolv.conf file (instead of /etc/resolv.conf) in RedHat Linux, similar to specifying custom hosts file via export HOSTALIASES=~/my_hosts? I don't have root access to the server.

Background: I need my ldapsearch command and hosts command to use my custom resolv.conf file instead of the default /etc/resolv.conf file

OS version: Red Hat Enterprise Linux Server release 6.9 (Santiago)

  • 1
    Nope, it's systemwide and that's it. – Michael Hampton Oct 25 '18 at 3:37

It's a path compiled into glibc, so your options are limited.
About the only solution I can think of (although I've never actually done this) would be to compile a custom resolver library to be used for your applications, and then run them with the LD_PRELOAD=/path/to/custom.resolver.library.so /path/to/your/app. You would need to know how to build a custom resolver library first, of course.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.