What is DNS Record?
Tags: starchart, senecaosd700, dnsrecord
Published: 2023-04-01 19:01:54

It's been about 10 weeks since I started working Starchar project which is the DNS service for student projects. At the beginning, many of us didn't have clear understanding about the terms like domain, subdomain, name, records, etc. Now I have a better understanding of these terms now. I would like to share the terms that I have learned in this project. 

### What is DNS Record?
A DNS record is a type of data stored in a domain name system (DNS) server that maps a domain name to an IP address or other information about the domain. So what Starchart will do is to create a DNS record that is connected to the user's IP address or domain. Also it can be linked with text type information. I will explain more details about these types.  


![starchart dns record creation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m88r5c6fj1qzjxm0cw3u.png)

### Types of DNS Record 
As I mentioned previously there are types of record that can be linked with domain name. Starchart supports A, AAAA, CNAME, TXT types. 

- A Record: Maps a domain name to an IPv4 address. So you can name your subdomain like `my-project`  and enter your public IP address as an A record. Your local project can be accessed via `my-project.user.mystudentproject.ca`. 
- AAAA Record: Maps a domain name to an IPv6 address. It works same as above. You just need to select AAAA type and enter IPv6 format IP address.
- CNAME (Canonical Name) Record: Maps a domain name to another domain name. If the user has an own domain already, it can be mapped with other domain name. So your project have two different domain names. Also CNAME is often used for subdomains. 
- TXT (Text) Record: Allows the domain owner to add arbitrary text to the DNS record. There are many different types of TXT records such as SPF, DKIM, DMARC, etc. This is one example of SPF record. 
```sh
"v=spf1 ip4:192.168.0.1/16 -all"
```
This specific TXT record means that use SPF version 1 and email should be sent from a range between `192.168.0.1` and `192.168.255.255` and deny all sources. You can find more details of other TXT record types in this [link](https://support.google.com/a/answer/2716800?hl=en#:~:text=TXT%20records%20are%20a%20type,outgoing%20email%20from%20your%20domain).

There are also other types of record as below. 
- MX (Mail Exchanger) Record: Specifies the mail server responsible for handling email for a domain.
- NS (Name Server) Record: Specifies the authoritative DNS server for a domain.


### What will Starchart do? 
Students can create their own subdomain under the root domain `mystudentproject.ca` using Starchart. Starchart will create a DNS record using student's subdomain name as well as HTTPS certificate. Then the project will be publicly accessed and secured on the internet. 
Route53 allows up to 10,000 records in one hosted zone which means same as 10,000 subdomains under `mystudentproject.ca`. Another hosted zone will incur more cost. You can plan the budget using AWS Route53 pricing [website](https://aws.amazon.com/route53/pricing).

### More Terms in DNS 
Route53 DNS records consist of `Type`, `Name`, `Value`, `TTL` and other optional values. Here `Name` means fully qualified domain name, aka `FQDN`. And Starchart only takes a subdomain from the user to complete the input for Route53 `Name`. `TTL` is Time to Live that decides how long it takes for record updates to reach the users. Longer TTL speeds up DNS lookups by increasing the chance of cached results, at the same time the updates to your records take longer to go into effect.


### Conclusion
We didn't have the right naming for domain related variables. One example is that I completely forgot what my variable `domain` meant even though I wrote the DNS code by myself. So we changed the variable names to either `fqdn` or `subdomain`. I can imagine later a new contributor would have great confusion from variable names. If I had a better knowledge, I would have used the appropriate naming. I hope this post is helpful to understand DNS record system and Starchart.