Page 1 of 2
How does DNS and sub-domain work?
Posted: Mon Mar 02, 2009 8:17 pm
by alex.barylski
Our ISP provides us with DNS -- so everytime we need to add or remove a sub-domain from the namespace we need to call our ISP and request they add one.
I assume this is done by DNS and they probably provide us with the nameservers?
If we were to bring this in house -- would we need two separate machines for the nameservers?
Can they not create a sub-domain record to use wildcards so whatever sub-domain we wanted we'd get?
How do wildcards work in DNS?
Re: How does DNS and sub-domain work?
Posted: Mon Mar 02, 2009 11:13 pm
by Eran
A sub domain is routed at the server level, not nameservers. The server which has the domain IP registered on can route it as it pleases - Apache for example can handle such routing by modifying the configuration file and adding <VirtualHost>'s
Re: How does DNS and sub-domain work?
Posted: Tue Mar 03, 2009 12:11 am
by josh
Usually bind is used. I've set up wildcards no prob. A lot of the control panels will explode if you put in a '*' but I assure you if you can edit bind files manually it will work. In your registrar there should be an option to "register nameservers" which actually adds your IP as the nameserver for your namespace, then you set up bind. Just like mail relaying tho a default bind install can be used by anyone as their DNS, so you'd probably want to harden the config so it only answers for domains you own
Re: How does DNS and sub-domain work?
Posted: Tue Mar 03, 2009 5:52 am
by VladSun
pytrin wrote:A sub domain is routed at the server level, not nameservers. The server which has the domain IP registered on can route it as it pleases - Apache for example can handle such routing by modifying the configuration file and adding <VirtualHost>'s
Can't agree with this one.
1. Internet is not only WWW services. A sub domain can run several different services.
2. A sub domain is still a domain, so a DNS is needed to resolve the IP. One may say everything is a sub domain of the TLDs, or even of the "." domain ( subdomain.domain.tld
. ). DNS is hierarchical by nature so a root domain (the ".") is required.
Apache uses HTTP host header to identify the request but the DNS is the one which resolves the proper IP Apache runs on. These are two absolutely different protocols (DNS and HTTP).
IP-based vs. Name-based:
http://httpd.apache.org/docs/1.3/vhosts/name-based.html
Mass virtual hosting
http://httpd.apache.org/docs/2.0/vhosts/mass.html
Re: How does DNS and sub-domain work?
Posted: Tue Mar 03, 2009 6:49 am
by Eran
You didn't understand what I said, cause I said the same thing. Using virtual hosts you can assign all subdomains to the same IP and control them via the server software such as Apache - that's all I said.
Re: How does DNS and sub-domain work?
Posted: Tue Mar 03, 2009 6:59 am
by Jenk
To extend what VladSun said, when you make a domain request, your machine polls the root domain to identify the machine. So let's take
http://www.example.com. The root domain will be asked to identify
http://www.example.com. It can't identify the entire address, but it can identify com - so it will then ask com to identify
http://www.example. The DNS cannot identify
http://www.example, but it can identify example - so again, the machine that is identified as example.com is asked to identify www. Whether it is a vHost or an A Record on a DNS server is irrelevant at this point.
Re: How does DNS and sub-domain work?
Posted: Tue Mar 03, 2009 10:25 am
by VladSun
pytrin wrote:You didn't understand what I said, cause I said the same thing. Using virtual hosts you can assign all subdomains to the same IP and control them via the server software such as Apache - that's all I said.
No, I didn't say that.
If you haven't setup a proper domain zone file, there is no way to have even a TCP connection to the Apache server - simply because nobody knows where
subdomain.domain.tld should be found - i.e. its IP address.
And if you try to reach it by IP address then HTTP host header won't work - so, one should always use a DNS in order to use VirtualHosts.
Using a wildcard for a subdomains of a domain is not the same as "A sub domain is routed at the server level, not nameservers." - that's what I argue about.
Re: How does DNS and sub-domain work?
Posted: Tue Mar 03, 2009 2:12 pm
by josh
Umm its both. A TCP connection can't be made until there is something listening on that port.
Re: How does DNS and sub-domain work?
Posted: Tue Mar 03, 2009 2:38 pm
by VladSun
josh wrote:Umm its both. A TCP connection can't be made until there is something listening on that port.
Who said anything about service availability? Also, ports are not related in any way to DNS.
I refered to "not even a TCP connection" only to emphasize that HTTP (as being on a much higher OSI layer) relies on DNS when Virtual hosting is used. Virtual hosting is not a substitute for DNS.
To summarize - one should have either per subdomain A (CNAME) records in the domain zone file or a wildcard. There is no way Apache Virtual hosting (the name-based one, of course) feature can be used without a properly set up DNS for the "virtual hosted" subdomains.
Re: How does DNS and sub-domain work?
Posted: Tue Mar 03, 2009 3:06 pm
by Eran
If you haven't setup a proper domain zone file, there is no way to have even a TCP connection to the Apache server - simply because nobody knows where subdomain.domain.tld should be found - i.e. its IP address.
I don't see how this contradicts what I said - I said that if the entire domain range (all subdomains) are assigned to the same server with the same IP, it can be handled by the server software such as Apace. This is a very common setup.
Re: How does DNS and sub-domain work?
Posted: Tue Mar 03, 2009 3:11 pm
by VladSun
Back again to:
pytrin wrote:A sub domain is routed at the server level, not nameservers. The server which has the domain IP registered on can route it as it pleases - Apache for example can handle such routing by modifying the configuration file and adding <VirtualHost>'s
It sounds like it is enough to have just the A record for the domain name, which is simply not true. And any of its subdomains are unresolvable.
I agree with your latest post, but I can't agree with your first post.
Re: How does DNS and sub-domain work?
Posted: Tue Mar 03, 2009 3:14 pm
by Eran
Yes I reread it and I see why - I made it sound like it's the only option. I meant it's a common setup (this was true for every server I used thus far).
Re: How does DNS and sub-domain work?
Posted: Tue Mar 03, 2009 3:22 pm
by josh
VladSun wrote:Who said anything about service availability?
A bit contrived don't you think? And to be fair pytrin did say "routing once the IP was registered with the machine". I doubt anyone was thick as to think apache handles DNS for you
Re: How does DNS and sub-domain work?
Posted: Tue Mar 03, 2009 3:48 pm
by VladSun
josh wrote:VladSun wrote:Who said anything about service availability?
A bit contrived don't you think? And to be fair pytrin did say "routing once the IP was registered with the machine". I doubt anyone was thick as to think apache handles DNS for you
You missed the "the
domain" part used in "subdomains" context from the quotation ... Interesting

And to be fair, I've answered at least 5 questions regarding "Why Apache virtual hosting doesn't work & do I need DNS setup" in other forums ...
Re: How does DNS and sub-domain work?
Posted: Tue Mar 03, 2009 4:18 pm
by josh
VladSun wrote:You missed the "the
domain" part used in "subdomains" context from the quotation ... Interesting

http://en.wikipedia.org/wiki/Straw_man you're right though, I know nothing about these inter-tubes*
* tongue very much in cheek.