How to create a subdomain and how do they work?

2019-03-12 10:59发布

问题:

I would like to create a subdomain off of my main domain for accessing my raspberry pi at home. My domain register company charges £10 for every subdomain so I thought there might be an easier (and cheaper) way of creating one. It would also help if I knew a little more about them and how they are created.

回答1:

DNS is built off of a hierarchy for scale-ability and/or for granularity.

If we take the a domain like www.stackoverflow.com. and break it down, here is what we get.

  1. www - This is the host portion of the domain. It is either an A record or a CNAME and eventually points to an ip address.
  2. stackoverflow - This is one of the domain levels. It has it's own DNS servers and config managed by the stackoverflow team. This allows that team to manage the entries specific to their needs.
  3. com - This is called a TLD (top level domain). All other domains that end in .com have an entry on the "com" dns servers.
  4. . - This is called the ROOT. There are 20 somodd root DNS servers scattered around the world. These servers are used to identify where the .com, .org, .edu, .gov, etc dns servers are.

From a client perspective what happens when you query www.stackoverflow.com is:

  1. You query the . name servers to ask where the com dns servers are.
  2. You query the com dns servers to ask where the stackoverflow dns servers are.
  3. you query the stackoverflow dns servers to ask where www is.

A subdomain simply means that you add an additional layer of DNS servers in the mix so that you can add more scale-ability and/or granularity to the mix.

For example, if our dns name is: www.foo.stackoverflow.com we would now have the foo dns server layer.

Having said that, I do not think that you need a subdomain. You probably just need an additional DNS A record or CNAME. For example:

raspberry.stackoverflow.com instead of raspberry.foo.stackoverflow.

They should not charge extra for additional host entries (A record or CNAME), only for subdomains.



标签: dns subdomain