I would like to know. When a domain example.com has an IP address: 41.72.111.222, would any of its subdomains (sub.example.com, mail.example.com etc) have the same IP address listed in the DNS records? Or does it work like this: A request is sent from the browser to the DNS server for sub.example.com. The DNS server returns the IP address for example.com, and the split/differentiation is made when the request for sub.example.com hits the example.com host server? So the host server basically know what to do with sub.example.com and not the DNS server?
1 Answer
It can kind of be a combination of both. Ultimately, though, the decisions are made based on what you set your DNS settings to be. Your host (or hosts) will then get whatever traffic you determined they should get in your DNS settings.
So for example...
You can set your DNS settings to take [anything].example.com and always direct that to your server. You would do this by adding a wildcard entry to your DNS subdomains. Wildcard entries use a * symbol to mean "anything". You would then need to configure your server to know what to do with all these different potential subdomains it could be receiving.
At the same time, you can set specific subdomains to go to other hosts. For example, if you wanted mail.example.com to go to some other webmail host, you would set up in your DNS the subdomain "mail" and have that traffic redirected to wherever you were hosting your webmail.
-
Thank you, but that kinda answer one part of my question, you just explained to me what happens once the request hits the host server. What happens when the request for sub.example.com is passed to a user's browser and in turn passed to that user's ISP DNS server? what IP will it assign? The IP for example.com? Jul 19, 2012 at 13:52
-
It will assign the same IP as example.com if you have set in your DNS for that to be the case. However, if you've set the IP for sub.example.com to go somewhere else, the traffic will go somewhere else. The host for example.com won't be involved at all. Jul 19, 2012 at 17:13
-
oh I see, so the DNS settings you talk about is set on your host web server right? Jul 20, 2012 at 6:26
-
1No, the DNS settings are all done at your domain name registrar. Like GoDaddy, NetworkSolutions, Register.com, etc... Jul 21, 2012 at 15:48