How does DNS and sub-domain work?

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

How does DNS and sub-domain work?

Post 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?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: How does DNS and sub-domain work?

Post 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
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: How does DNS and sub-domain work?

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: How does DNS and sub-domain work?

Post 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
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: How does DNS and sub-domain work?

Post 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.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Re: How does DNS and sub-domain work?

Post 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.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: How does DNS and sub-domain work?

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: How does DNS and sub-domain work?

Post by josh »

Umm its both. A TCP connection can't be made until there is something listening on that port.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: How does DNS and sub-domain work?

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: How does DNS and sub-domain work?

Post 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.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: How does DNS and sub-domain work?

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: How does DNS and sub-domain work?

Post 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).
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: How does DNS and sub-domain work?

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: How does DNS and sub-domain work?

Post 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 ...
There are 10 types of people in this world, those who understand binary and those who don't
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: How does DNS and sub-domain work?

Post 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.
Last edited by josh on Tue Mar 03, 2009 4:21 pm, edited 1 time in total.
Post Reply