Your Internet Service Provider will likely push the DNS server information through the DHCP protocol (of course, you can override this information locally on your machine). This is how your machine will get configured with DNS servers to launch queries against.
The way a CDN works is as follows: companies relying on CDN based delivery of their contents will manage their domains through a CDN provider. When a request comes for say domain D
, a machine will contact its configured DNS server and will be directed to the "authoritative entity" for the domain D
in question. From this point, the CDN DNS server can reply with an answer that provides a binding to an IP address "closest" to where the request originated.
The property "closest" is determined, amongst other things, based on the requesting machine's IP address. It is nonetheless non-trivial to assign a "metric" based on this information: there is no direct correlation between "IP address" and "physical location", vital information for effecting as best as possible contents to the requesting machines.