DNS: Domain Name System
- Facilitates the mapping of website name to ip address and vice versa
unordered_map<string,string>mp;
mp["www.shubhamiitbhu.in"]="76.76.21.22"
unordered_map<string,string>mp;
mp["76.76.21.22"]="www.shubhamiitbhu.in"
graph LR;
A[Local Machine<br>IP: 12.123.43.255]-->B((ISP))--IPv4<br>internet-->D((ISP))--IPv4<br>internet-->C((ISP))-->E[Destination Machine<br>76.76.21.22:443]
- After this request, a packet is generated by our browser
graph TB;
A[HTML Payload:Get www.shubhamiitbhu.in/profile ]
subgraph IPs
B[Source Ip:12.123.43.255]
C[Destination Ip:76.76.21.22]
end
D[Data Link Layer Hdr]
A-->B
A-->C
B-->D
C-->D
- How our machine knows the ip address of the destination machine?
- It sends a request to the DNS server
- DNS server is a server which maintains a mapping of website name to ip address
- It is maintained by the ISP
- It is a distributed database
- It is a distributed database because it is not possible to maintain a single database for all
the websites in the world
- DNS
- Application Layer Protocol
- It uses UDP
- It uses port 53
- works completely transparently to the user
graph LR;
A[Local Machine]
B[ISP]
C[Internet]
E[Google Server]
F[Facebook Server]
G[Amazon Server]
A-->B
B-->C
C-->E
C-->F
C-->G
DNS System Architecture &
Geographical Distribution
- DNS system is a group of DNS servers which works in collaboration with each other to implement the DNS
system
- DNS servers are distributed geographically
- DNS Machines are managed and monitored by central authority
- Global DNS Server machine works at two levels
- Root DNS Server
- Top Level Domain Server
DNS : A Hierarchical and Decentralised
System
![Alt text](image.png)
Literals in C
int a=10;
int ->keyword
a ->identifier
10 ->literal
= ->punctuator
graph TD;
A[Literals]-->B[Number Constants]
A-->C[Character Constants]
B-->D[Integer]
B-->E[Floating Point]
D-->F[Decimal]
D-->G[Octal]
D-->H[Hexadecimal]
D-->I[Binary]
F-->J[Unsigned]
F-->K[Signed]
J-->L[Integer<br>4 Bytes<br>32 bits]
J-->M[Long Integer <br>8/4 Bytes]
J-->N[Long Long Integer<br> 8 Bytes]
K-->O[Integer]
K-->P[Long Integer]
K-->Q[Long Long Integer]
E-->R[Float<br> 4 Bytes]
E-->S[Double <br>8 Bytes]
E-->T[Long Double <br>16 Bytes]
C-->U[Single Character<br>1 Byte]
C-->V[Multiple Characters<br>String]
Website Domain Name
- A Website Domain Name consists of individual words called literals separated by dots
- Each literal is called a label
go.learn.shubhamiitbhu.in
consists of 4 literals
[go,learn,shubhamiitbhu,in]
this is opposite of DNS hierarchy
in->Top Level Domain TLDs
shubhamiitbhu->Shubham's DNS Server
learn->Shubham's sub DNS Server
go->Shubham's Server that is hosting the website(Not a DNS Server)
FQDN: Fully Qualified Domain Name
First Hope DNS Server
- First Hope DNS Server is the DNS Server which is contacted by our machine
- It is the DNS Server of our ISP
- Our local machine first contacts the First Hope DNS Server to get the ip address of the destination
machine
- Our local machine also have some DNS cache which stores the ip address of the frequently visited
websites / recently visited websites
- Our local machine knows the ip address of the First Hope DNS Server because it is configured in the
network settings of our machine by the ISP when we connect to the internet
DNS Resolver
- DNS Resolver is a software which is present in our local machine
- It is responsible for contacting the First Hope DNS Server
- It is also responsible for maintaining the DNS cache
- It is also responsible for sending the DNS request to the First Hope DNS Server
- It is also responsible for receiving the DNS response from the First Hope DNS Server
- It is also responsible for sending the DNS response to the browser
- It is also responsible for sending the DNS response to the browser
DNS Query Types
graph TB;
A[Query Type]
B[Recursive Query]
C[Iterative Query]
D[Reverse Query]
A-->B
A-->C
A-->D
Recursive DNS Query
![1704534231478](image/DNS/1704534231478.png)
Iterative DNS Query
![1704534375623](image/DNS/1704534375623.png)
![1704534404336](image/DNS/1704534404336.png)
Reverse DNS Query
![1704534498354](image/DNS/1704534498354.png)
![1704534550294](image/DNS/1704534550294.png)
![1704534619718](image/DNS/1704534619718.png)