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

4

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 10.0.0.1 for everything
except use 10.0.0.2 for "mycompany.net"

Edit: adding more detail.

I am trying to VPN into my company's server. Everything almost works great following this guide: http://www.cyberciti.biz/tips/howto-configure-ubuntu-fedora-linux-pptp-client.html

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.

user3875

Posted 2009-09-09T23:22:17.653

Reputation: 143

Answers

6

Not directly.

But you could run your own local DNS server which is configured with details to serve for mycompany.net 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?

David Spillett

Posted 2009-09-09T23:22:17.653

Reputation: 22 424

Sorry, I didn't word it very well. Let me add more details to the question. – user3875 – 2009-09-09T23:39:39.163

That works! Thank you. Now that I added more detail, is there a simpler way? I'm just curious because this works great. – user3875 – 2009-09-09T23:44:08.843

If your company's DNS server was configured to allow you do perform recursive queries when accessing via the VPN, then you would not need the local server yourself. You could also try the hosts file approach but that can be a hassle to maintain so isn't recommended. – David Spillett – 2009-09-10T19:05:12.520

0

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.

Kim

Posted 2009-09-09T23:22:17.653

Reputation: 2 238

That would be a poor solution because this information will quickly become stale. Never put in a static file data which is outside of your control. – bortzmeyer – 2009-09-10T07:51:32.407

How practical that is of course depends on the size of his company's network (and the number of computers he needs access to there). In some cases that's just 1 or 2 servers. – Kim – 2009-09-10T11:18:05.860