How can I set up Linux to use a different DNS server for a certain domain?

Posted on

Problem :

I can add DNS servers to resolv.conf and that works fine.

But is it possible for me to call a different DNS server based on the domain trying to be resolved?

For example:

use for everything
except use for ""

Edit: adding more detail.

I am trying to VPN into my company’s server. Everything almost works great following this guide:

DNS resolution doesn’t work for me. The article suggests modifying resolv.conf with the DNS servers.

When I have the first nameserver in the list as my own router, resolution of names on the VPN doesn’t work. When I have the first nameserver as my company’s router, resolution of names on the Internet doesn’t work.

Solution :

Not directly.

But you could run your own local DNS server which is configured with details to serve for and forward requests for other domains to your normal servers.

I may not be reading your question right – can you go into more detail about the problem that what you are asking for would solve?

You could also put the data for your company’s network into your /etc/hosts file. That way you don’t have to run a DNS server on your own computer.

Leave a Reply

Your email address will not be published. Required fields are marked *