How to use a subdomain as if it were a domain

Asked

Viewed 12,623 times

2

How can I create 2 subdomains via DNS?

I need to create 1 for each server and use them as if it were a domain.

I own 2 servers, one on BR and the other in the USA.

What I want is to do this:

srvbr.meudominio.com -> Point to BR Server

srveua.meudominio.com -> Point to US Server

  • 2

    You need to access your DNS provider and create two ADRESS-type records for the respective subdomains and IP servers. Creating CNAME’s also works, but then servers need to have a domain.

  • 1

    @Wakim elaborates more his comment and turns in response.

  • 1

    @Renan, done :)

2 answers

7


At @Renan’s suggestion, I will try to elaborate my answer better, although I am not an expert on DNS :)

But there are two ways (as far as I know) to create subdomains for a given host. Or by records Address or by CNAME.

1. Log in to your DNS provider

There you can create, update, delete DNS records. Remembering that these changes, if memory serves, take a certain amount of time to be applied (up to 48 hours, at @brasofilo’s suggestion) because it does not depend only on your provider, the new registration needs to propagate between the TLD’s higher level and etc...

I believe that when entering your provider, you will see a screen similar to this:

inserir a descrição da imagem aqui

I don’t know how the changes of TTL (Timetolive) influence performance, since when the TTL of a record ends, it is necessary to consult the TLD’s higher level, which can lead to lost time consulting DNS, since the cache of DNS is made based on the TTL.

2. Creating ADDRESS type records (A)

If you know the IP’s servers and they won’t change, so just create a record like To for each with the value:

srvbr.meudominio.com IN A IP.do.Servidor.BR
srveua.meudominio.com IN A IP.do.Servidor.EUA

And wait a certain period for the record to spread.

3. Creating CNAME type records

The records of type CNAME do not accept IP’s, they are aliases ("shortcuts") for domains. That is, if I create a CNAME record of:

srvbr.meudominio.com IN CNAME srvbr.com
srveua.meudominio.com IN CNAME srveua.com

When someone is solving the DNS (browser, whoever), the address srvbr.meudominio.com will point to the srvbr.with.

With this strategy, you need to configure a domain for each server, that is, you need each server to have an Address record pointing to the IP. According to this question of the OS, CNAME does not accept values of type IP.

In the end it would have something like:

srvbr.com IN A xxx.xxx.xxx.xxx
svreua.com IN A yyy.yyy.yyy.yyy

srvbr.dominio.com IN CNAME srvbr.com
srveua.dominio.com IN CNAME srveua.com

Practical example:

I I don’t have hosting for a personal page of mine, but I do have a personal page on Github Pages. What I do: I created a CNAME that points to my domain meudominio.with to the menunome.github.io. Given that I cannot trust the IP (registration type A), which is not under my control.

If I made any theoretical mistake, I’m sorry because I’m not an extreme DNS expert. Feel free to suggest changes

Some suggestions for reading:

  1. Cname_record
  2. understanding them-dns-records-aaaa-ns
  3. Differences-between-a-cname-alias-url
  4. cname-record
  • I didn’t understand, to work I wouldn’t have to put: srveua.dominio.com IN CNAME ns1.abcdefgh.com and srveua.dominio.com IN CNAME ns2.abcdefgh.com this example I did, is only for the srveua.dominio.com subdomain

  • 1

    That, I was confused with your question. I thought they were ns1 and ns2, one for the US server and one for the br server. But I think you understand the concept, where there’s a subdomain that points to another domain.

  • In case I have to put the IP from the server in the type log [A], and then create two CNAMES equal, changing only ns1. and ns.2 ? Then I can turn the subdomain into a "domain" and point it to another server? : D

  • @Alexandrelopes, if your servers already have a domain, you don’t need to create a registry [A], only if you want to. Only CNAME.

-3

I do this on several occasions and it always works with the.br record, using their dns to make Record A notes. I still can’t get through with the . with bought together with Godaddy, because their panel seemed confusing and simply does not work as expected. At least for me.

I do exactly as the colleague suggested above, except that I do not use cname, because it does not seem necessary, since I have two ips purchased one on a server and the other on another.

srvbr.com IN A xxx.xxx.xxx.xxx svreua.com IN A yyy.yyy.yyy.yyy

  • 2

    The answer in question does not efficiently cover the question, leaving room for doubts and different interpretations. In your answers try to be objective and clear, I believe your answer would be better as a comment.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.