This is a setup section for the Domain Name System (DNS) project.
- Clone repo
git clone https://github.com/tdadadavid/go-dns.git
- Install dependencies
go mod tidy- Run command to start the DNS server.
make run- Run command to lookup domain using this DNS resolver.
nslookup <desired domain> localhost -port=8090This category of records contains the information about the IP address of a domain name. The IP address is used to locate the server that hosts the website or service. It is divide into 2
- A (IPv4 Address); this is used to store the IPv4 address of a domain name.
- AAAA (IPv6 Address); this is used to store the IPv6 address of a domain name.
# get the ipv4 address of google.com
dig google.com -t A # get the ipv6 address of google.com
dig google.com -t AAAAThis is used create alias for a domain name. For example if you have domain with example.com, and you also have docs.example.com, drive.example.com, these records still point to the same IP Address (example.com) but with different hostnames.
| Host | Type | Value |
|---|---|---|
| example.com | A | 142.234.53.1 |
| docs.example.com | CNAME | example.com |
| drive.example.com | CNAME | example.com |
| mail.example.com | CNAME | example.com |
This record is how servers know which mail server to use for a domain name. It is used to specify the mail server that is responsible for accepting email messages for a domain name. For example I (obadafidi@example.com) sends a mail to my friend (tolulope@yahoo.com) the DNS resolution flow will be like this
- The DNS resolver will first look up the MX record for the domain name
example.com. - The MX record will specify the mail server that is responsible for accepting email messages for the domain name
example.com. - The DNS resolver will then look up the IP address of the mail server using the A record (IPv4)
- The mail server will then accept the email message and deliver it to the recipient email server (
yahoo.com) - Then the mail server on
yahoo.comwill authenticate the email message to ensure it is from a trusted source. - The mail server on
yahoo.comwill then deliver the email message to the recipient's email once verification is complete.
sequenceDiagram
participant Obadafidi as Obadafidi@example.com
participant GMail as GMail Mail Server
participant DNS as DNS Server
participant Yahoo as Yahoo Mail Server
participant Tolulope as tolulope@yahoo.com
Note over Bob,GMail: MX Record Resolution & Mail Delivery Process
Bob->>GMail: (1) Sends email to tolulope@yahoo.com
GMail->>DNS: (2) Requests MX record for yahoo.com
DNS-->>GMail: (3) Returns MX record (Yahoo Mail Server details)
GMail->>DNS: (3b) Resolves A record to get IP address of Yahoo Mail Server
GMail->>Yahoo: (4) Sends mail data to Yahoo Mail Server
Yahoo->>DNS: (5) Verifies that sending mail server (GMail) is authenticated
DNS-->>Yahoo: Returns authentication confirmation (SPF/DKIM/DMARC)
Yahoo->>Tolulope: (6) Delivers email to tolulope@yahoo.com
The server responds with the domain name and IP for address for amazon.com
Same thing happens for google.com
- [] Write DSN parser
- [] Implement TLS/SSL support
- [] Add support for other DNS record types (TXT, CNAME, etc.)




