DNS gets involved primarily in answering something like gethostbyname
(i.e., finding the numeric address that goes with a given host name). In a few cases your computer's own IP stack will answer such questions without consulting a DNS, typically by getting the address from your local HOSTS file. This was common at one time, but has long since become relatively rare (HOSTS files are still of some use in testing, as well as being used by some malware to re-direct some requests to a machine of the malware author's choosing).
When you send to that address, your computer's IP stack will sort out where to sent it from there. First it uses the subnet mask to figure out whether the address is "local" or not. If it's local, it'll use ARP to find the Ethernet MAC address (or whatever, but nowadays mostly Ethernet) to which to send the packet. If the address isn't local, it'll send it to the default gateway address.
Assuming it's not local, the default gateway will normally be your router. Your router will send it on to the ISP's router, which will then send it on to another and another until it gets where it's supposed to be going. There are some protocols (RIP, RIPv2, etc.) for routers to tell each other how to get packets from one place to another. For a typical home router, things are simple: anything that isn't local goes to one place. For a larger router at an ISP, things are a little more complex -- it'll frequently have several other places it could sent your packet. RIP (and friends) give it enough information to pick the "right" one (i.e., the one that's likely the best choice).
If you want to see where your packets go, most systems provide a program named tracert
that will trace the route from your machine to another you specify.
I see @normalocity has posted an answer already. I'd be cautious about one thing though: he mentions the router getting your packet closer to its destination. This is true, but only in a rather virtual sense, not a physical one. Just for example, at one time I used tracert to trace the route from my machine at home to a machine downtown, about 5 miles away or so. Even though both machines were in Colorado Springs, Colorado, my packets were routed to Denver, and then on to San Jose before coming back and getting to another reasonably local machine.
1
Really you're asking about what happens at the transport level, not the physical level - check out http://en.wikipedia.org/wiki/Osi_model for more on the different levels.
– Brian Driscoll – 2011-12-01T22:00:49.313You are really asking the question -- how does the Internet work. Lots of good explanations can be found online. Such as this one and this one.
– David Schwartz – 2011-12-02T00:30:39.553Don't get too hung up on the OSI protocol model, since the Internet has its own model, the TCP/IP model. – sawdust – 2011-12-02T02:03:59.523