When you use a DNS server, for either IP address or hostname, that is what it gives you. It does not direct you towards any web server, that is not its purpose.
When a browser wants to connect to a web server what it does first of all, is to ask someone for its IP address. That someone is usually a DNS server. The DNS server replies and the browser then happily goes on to connect to the web server.
Secondary DNS servers are there mostly as backup for the primary, since most function on the Internet is so dependent on these servers being available.
Another thing you should know about DNS is that it is built using a distributed hierachy of global to local information. So when a server changes IP address it will take some time for that to propagate around the world.
In most circumstances it is not a good idea to have both a web server and a DNS server on the same machine. There isn't anything that will stop you from doing so, but it is not smart seen from a security point of view.
Alf
it will take some time for that to propagate around the world
My experience it is can take up to about a week. My ISP requires 5 days, earthlink seems to be about a day, my own DNS servers expire domain names after a week.
So if you are moving a site from one host to another (and I've done it a dozen times in the last year), be sure you take this into account. Also, if something breaks in your DNS (say you tried to change the MX to bigmailbox and it was messed up) then several days will be required for the screw up to propogate, then the fix.
In most circumstances it is not a good idea to have both a web server and a DNS server on the same machine
I've been doing this for some time with no issues, although it is true that it's generally not considered wise to mix any two servers on the same machine. You normally do not want to put, for example, your email server on the same machine as your web server. It just makes the machine more complex to manage and allows for multiple forms of attack to the same machine.
Basically you can think of it as distributed phone-book that can work in both ways.
See RFC 1912, 1537, 821, 822 and others for more information. I have all of the RFC's on my site and they are on numerous other sites as well. They are very interesting reading and contain the source data about how it all works.
RIchard Lowe