Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to create a host file on a custom location (ex. /opt/app/hosts) with the same formatting as the /etc/hosts file.

The reason for this is that I want to manually query a DNS server for a specific range of hosts and write those to my own custom host file. I can't add that DNS server to the /etc/resolv.conf because I don't want the server to try resolving hosts with it (apart from the small subset that I query manually).

I've tried searching for a way to include it in /etc/hosts or configure it in /etc/nsswitch.conf or /etc/resolv.conf but as far as I can tell neither of these configuration files contain.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

You can setup BIND to forward requests for specific domains to specific DNS server:

zone "some.domain"
{
        type forward;
        forwarders { 10.0.0.1; };
};

All other requests will be forwarded to servers specified in global options::forwarders section. Probably, this is the best way to achieve what you want.

share|improve this answer

dnsmasq can do this (and more); it allows you to use any local name database in addition to the regular hosts file and DNS with one easy switch:

dnsmasq -H /opt/app/hosts

share|improve this answer
    
You can also use dnsmasq as a proxy to send all dns requests through to your normal name server, and then send these specific requests on through to the special name server. This way you dont have to keep anything local and do manual updates when it changes. –  Patrick Nov 2 '11 at 13:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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