Basics of HTTP & DNS
Basics of HTTP/How the internet and web work
What is DNS:
Whenever we type in the website name such as google.com how would our computer know which computer to communicate with in order to show/fetch us the information and get our work done? This thing is managed using DNS (Domain Name System)
Work of DNS is to convert google.com into a number (Internet Protocol Address aka IP address).
- Go to Inspect element in any website -> Networks -> Docs -> website.com -> And see the remote address. This remote address is the conversion of the site into an address using DNS
How does DNS work?
So basically it contacts with the DNS resolver on your computer. (Either ISP provides it or you have to Manually add it)
So what is DNS resolver? : A DNS resolver is a hard coded IP address given to your computer to generate a request like (ip address of website.com).
Common Primary DNS of computer is
- This means the computer is going to ask what is ip address of website.com with the help of
It takes a question from a client (browser or OS).
Client asks the
184.108.40.206for the IP address of the website.com
220.127.116.11calls a another DNS(1) and asks him what is the IP address of domains with ".com" are stored. It return a another DNS(2)
18.104.22.168calls a DNS(2) and asks him for the IP address of website.com. Then it returns the another DNS(3).
22.214.171.124calls a DNS(3) and asks for the IP address of the website.com. Then it returns the IP address of the website.com
- After this it gets connected to the website.com
126.96.36.199may cache the IP address of website.com to save the time in the next call
There are certain rules to be followed by the client and the server in order to establish a successful communication.
What is HTTP:
- It is a plain text protocol.
So when you go to the Request headers in the Network -> Doc -> Request headers. What ever you see is the response needed by the client to establish a successful network with the IP address.
What is Status Code?
HTTPresponse status codes indicate whether a specific
HTTPrequest has been successfully completed. Responses are grouped in five classes:
- Informational responses (
- Successful responses (
- Redirects (
- Client errors (
- Server errors (
500–599) Check more here
What are port numbers?
- Informational responses (
For example if the computer runs the http and ftp at the same time. How would a server know which service should handle it if the query is comming from the computer. This task is handled by the ports (eg: 188.8.131.52:80) so 80 si the port here (anything after
- Some comman port numbers
- Each internet protocol is associated with a default port
194) Check more here
- Whenever you make a request the computer is listening to the post number.
- It is not mandatory to use example.com:443 as it is predefied but if your have a service running on other port than 443 then you might require to use example.com:333 here 333 is a port defined by us
In this way the computer can manage different services cleanly and simultaneously
What are Request Methods?
When we are done with resolving the IP address to the domain name and the port, the next thing it is going to do is sending a request methods.
It is the very first thing which is sent when a connection is established between client and a server.
GET- It is only used when there is no sending of data from the client to the server (eg : uploading the files, photos)
POST- Is used when you want to send the data or interact with the server. eg: (login) Get more here
POSTare the most important methods. You can pretty much do anything with this methods.
POSTis superior than any other method because it can function like
PUTetc. because it works on the body.
What are Request Headers?
HTTP headers let the client and the server pass additional information with an HTTP request or response. An HTTP header consists of its case-insensitive name followed by a colon (:), then by its value. Whitespace before the value is ignored.
Headers can be grouped according to their contexts:
- General headers apply to both requests and responses, but with no relation to the data transmitted in the body.
- Request headers contain more information about the resource to be fetched, or about the client requesting the resource.
- Response headers hold additional information about the response, like its location or about the server providing it.
- Entity headers contain information about the body of the resource, like its content length or MIME type.
Headers can also be grouped according to how proxies handle them:
- Upgrade (see also Protocol upgrade mechanism). Check out more infor here
Raw HTTP requests using netcat :
- Open netcat shell
- Type in command
nc example.com 80 -vvvThis will establish the connection to example.com by port 80.
- Then type `GET / HTTP/ 1.1
- Then type
Host : example.com. This is mandatory after 1.1 (if we use GET/ HTTP/ 1 then you can skip it)
- Then just simply hit enter
- In this way you can learn to establish the network successfully