sub-domains mapped to remote servers

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

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

sub-domains mapped to remote servers

Post by alex.barylski »

I'm curious. Is it possible to have a web site hosted at some server in say Chicago and have a sub-domain mapped to a server in say India?

Something like:

http://www.mydomain.com = 122.76.23.54 (Chicago)
sub.mydomain.com = 178.111.123.43 (India)

Ignoring the random IP's is this possible? What would I search on Google to learn more about this?
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

yes sure,

just change it in the dns server.
maybe your domain host has a dns section, just point the sub to the other ip.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Re: sub-domains mapped to remote servers

Post by timvw »

Hockey wrote:I'm curious. Is it possible to have a web site hosted at some server in say Chicago and have a sub-domain mapped to a server in say India?
And for e-mail, it gets even better because you've got MX records for that. This way, all example.com will resolve to 123.456.789.xyz, and all e-mail for example.com will be delivered at xyz.klm.abc.mno.
Hockey wrote: What would I search on Google to learn more about this?
A simple getting started with dns tutorial? (probably a websearch for bind9 tutorial might help too.. Not that i would recommend such a large dns deamon for 'home' usage ;))
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Bind is nasty...

I have a Linux Admin Handbook and a HUGE portion of the book is dedicated to DNS and Bind...boring reading...but I"m slowly picking it up. :P
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

Hope that DNSSec is not going to be implemented at the time you finish reading it ... because that's nasty :) :) :)
There are 10 types of people in this world, those who understand binary and those who don't
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: sub-domains mapped to remote servers

Post by alex.barylski »

Edit:
wikipedia wrote:The Domain Name system distributes the responsibility for assigning domain names and mapping them to IP networks by allowing an authoritative server for each domain to keep track of its own changes, avoiding the need for a central registrar to be continually consulted and updated
Ahhh...so there is a single authorative source for .ca .com .net etc...which manage DNS for each of those. Registrars like GoDaddy must work under those servers. Thats why not all registras are created equal - you can't buy .ca from GoDaddy.com...this is why a DNS on my dedicated server that mapped my web site domain to Google's IP address wouldn't do anything because that mapping needs to be stored on the .com central server DNS and/or the .ca...am I correct?

So to ask another question: What good would having a local DNS do me?

--- I believe the following has been answered above ---

I'm confused. DNS sounds like a single central server which maintains a map of IP addresses and their repspective domains. Although logic is telling me this isn't the case, as one server to handle all that traffic, domains, etc would be savage. Also, the fact that I have read a few pages on DNS and it seems I can set one up locally. This makes me think it's a distrubuted effort but also begs the question:

What happens if I access an domain name and the DNS which is closest to me geographically doesn't contain the mapping to IP address for my selected domain? This is why I'm thinking...if the service is distributed...they must all be aware of each other inorder to forward requests onto each other until the domain can be resolved into IP.

How do these servers know of each other? Are they all registered with a central server or is it more adhoc, in that they ping IP addresses until one responds as DNS server. :P

How does a DNS become officially registered in this central database of recognized servers? Who decides which domain's it' maps to? If I rent a dedicated server and setup a DNS myself and map google.ca to an invalid IP which is actually my web site...what stops that from happening?

Cheers :)
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: sub-domains mapped to remote servers

Post by Kieran Huggins »

It's like a big tree - domain "authority" is assigned from right to left.

The TLD (top level domains) like COM, NET, ORG, CA, etc.. are the roots of each tree and are well known. There are an array of a dozen or servers for each, IIRC, and they keep a list of which DNS servers have "authority" over every domain with that extension. This pattern repeats as often as it needs to, but usually only two or three times in total.

Example: lolcat.kieran.ca - first it looks at the "CA" and knows to ask the root CA server who the hell "kieran" is. CA has no idea, and forwards the request to the DNS server assigned to "kieran.ca" (which is all it knows). The request come in to the "kieran.ca" nameserver and it looks up the entry for "lolcat", then returns the IP.

To save the load on the root DNS servers, other DNS servers will often save a local copy of the info and server that instead of always passing on your lookup to the root servers. This cache is what needs to be "refreshed" when you update a DNS record... it usually takes between a few hours to a day to make it EVERYWHERE - but is often mostly (usably) propagated within an hour or two.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: sub-domains mapped to remote servers

Post by VladSun »

:)

run

Code: Select all

dig dir.bg +trace
and look at the result.

When you ask your DNS client to resolve a domain the following steps are performed:

0.Your DNS client looks at its cache and if the domain is already there it returns the IP. The cache live time is defined by the DNS serving the domain - so called TTL.

If the domain name is not in the cache
1. There are 13 of so called ROOT DNS servers which when queried give information about which DNS (or a list of them) serves top level domains (.com, .net, etc.) or the TLD (.ca, .co.uk, etc.) of the queried domain. Your DNS client queries them.
2. Your DNS client receives a list of DNS serving the required top level domain or TLD. Then your DNS client query one of these server (in round-robin manner).
3. The queried server returns a list of servers serving the domain.
4. Your DNS client queries one of them - the answer can be an IP address or a CNAME - an alias for another (sub)domain or subdomain. If it's a CNAME then a new query is performed, but this time for the IP of the CNAME (sub)domain.
5. The result is cached for TTL-value of time.

One of the NS servers serving a domain zone is a primary - all changes are made in its config files. The others are secondary NS - they receive so called "notification" on every change done in the primary server. This notification has a serial number (YYYYMMDDXX) - if the serial number is greater than the one of the last notification an update is preformed.
There are 10 types of people in this world, those who understand binary and those who don't
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: sub-domains mapped to remote servers

Post by alex.barylski »

Ok I just read a few more chapters on DNS and Bind...

I see now how domain are hiararchial in nature. Resolution starts with the top-level domain (CA, COM, NET, etc) and works it's way left. This is why a FQDN should have an appended '.' - makes sense now.

Few more questions:

* I still need to polish my understanding, especially on Zones, ROA, etc so bear with me... :P

1) First I read DNS then I read Bind. As I understand DNS is the concept and Bind is the implementation. Before Bind, historically speaking, this was when netwrosk were small and /etc/hosts were used. As the Internet grew and become a global phenom a new method was needed and thus BIND was introduced.

Not sure where the /etc/hosts comes into play but I re-call tinkering with it a while back to emulate sub-domains on localhost...so I guess it has use there. Locally I should not likley need to run a bind server such as named, correct???

If so, when would I?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: sub-domains mapped to remote servers

Post by VladSun »

You could use /etc/hosts to "emulate" DNS - but it would work only on the server itself. If you are on remote PC you need to edit its /etc/hosts. (Don't forget to configure your virtual domains section in apache config).
As a second option, you have to install and run named with apropriate config and domain name zones. Then configure your client PC to use this server for DNS.
And ideally, if your hosting company permits it, you could point the DNS for your domain to be the server you have run named on.
There are 10 types of people in this world, those who understand binary and those who don't
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: sub-domains mapped to remote servers

Post by alex.barylski »

So in order for me to accomplish this, I would have to likely request the hosting account (shared) update their CNAME or A records to point my sub-domain at another remote server???

Code: Select all

server1    IN      A      192.168.0.3
www        IN      CNAME  server1
ftp        IN      CNAME  server1
 
myapp    IN    CNAME    myapp.mydomain.com
The last record being the one which maps the sub-domain myapp.server1.com to myapp.mydomain.com???

I usually buy domains through GoDaddy.com - it appears I would need to use their DNS servers inorder to have that control over the DNS. Unfortunately I do not host with GoDaddy and therefore I typically change my DNS servers to reflect those of my shared host or dedicated host. Assuming the former (shared hosting) would I just request they add the appropriate record?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: sub-domains mapped to remote servers

Post by VladSun »

First you forgot to put a dot after myapp.mydomain.com. In the way it's typed now, it means
myapp.mydomain.com.server1.com

Second, CNAME means an "alias" for subdomain/domain already defined by an A record.

And third, to avoid a second DNS look up for myapp.mydomain.com use its IP instead.

So, finally we have:

myapp IN A IP_of_myapp.mydomain.com
There are 10 types of people in this world, those who understand binary and those who don't
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: sub-domains mapped to remote servers

Post by alex.barylski »

myapp IN A IP_of_myapp.mydomain.com
I'm confused...why would I need to use the IP_OF_MY_APP.mydomain.com instead of the sub-domain myapp.mydomain.com

Second, assuming I buy domains from GoDaddy...and I rent shared space from some other hosting company and therefore use their DNS servers - not GoDaddy's...so I need to ask each host before I signup, whether they would map sub-domains to another server for me??? Seems a simple task, so if they charge me for it, I think I'd just keep looking for another host.

Cheers :)
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: sub-domains mapped to remote servers

Post by VladSun »

Hockey wrote:
myapp IN A IP_of_myapp.mydomain.com
I'm confused...why would I need to use the IP_OF_MY_APP.mydomain.com instead of the sub-domain myapp.mydomain.com
Let's suppose you have:

Code: Select all

myapp    IN    CNAME    myapp.mydomain.com.
Then a DNS query would return:

Code: Select all

dig myapp.server1.com
;; ANSWER SECTION:
myapp.server1.com.         XXXXXX   IN      CNAME   myapp.mydomain.com.
myapp.mydomain.com.      XXXXXX     IN      A       10.0.0.1
 
So, you see - there are two DNS queries performed in order to resolve the IP of myapp.server1.com.

If you put:

Code: Select all

myapp    IN    A    10.0.0.1
then only one DNS query would be needed.
Hockey wrote:Second, assuming I buy domains from GoDaddy...and I rent shared space from some other hosting company and therefore use their DNS servers - not GoDaddy's...
That's not true - you may use whatever DNS server you want (including GoDaddy's one).
Hockey wrote:so I need to ask each host before I signup, whether they would map sub-domains to another server for me??? Seems a simple task, so if they charge me for it, I think I'd just keep looking for another host.
Again, you can ask GoDaddy to change the NS records to the DNS servers of your hosting provider.
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply