3 minute read

Address Formats

  • IPv4 : 32 bits / 4 bytes
  • IPv6 : 128 bits / 16 bytes
  • Mac address : 48 bits / 6 bytes

note : telnet uses tcp

default port

| Port | Use | | :——–: | :——-: | | 20,21 | ftp | | 22 | ssh | | 25 | smtp | | 53 | dns | | 80 | http | | 443 | https |

Sockets

Sockets allow communication between two different processes on the same or different machines. Normally, a server runs on a specific computer and has a socket that is bound to a specific port number. The server just waits, listening to the socket for a client to make a connection request.

four types of sockets available to the users. The first two are most commonly used and the last two are rarely used :-

  1. Stream Sockets : Delivery in a networked environment is guaranteed. If you send through the stream socket three items “A, B, C”, they will arrive in the same order − “A, B, C”. These sockets use TCP (Transmission Control Protocol) for data transmission. If delivery is impossible, the sender receives an error

  2. Datagram Sockets : Delivery in a networked environment is not guaranteed. They’re connectionless because you don’t need to have an open connection as in Stream Sockets − you build a packet with the destination information and send it out. They use UDP (User Datagram Protocol).

  3. Raw Sockets : These provide users access to the underlying communication protocols, which support socket abstractions. These sockets are normally datagram oriented. intended for people trying to make new protocols

  4. Sequenced Packet Sockets : They are similar to a stream socket, with the exception that record boundaries are preserved

DNS

The Domain Name System (DNS) is the phonebook of the Internet. Humans access information online through domain names.

Steps :-

  1. User types ‘example.com’ into a web browser and the query travels into the Internet and is received by a DNS recursive resolver.
  2. The resolver then queries a DNS root nameserver (.).
  3. The root server then responds to the resolver with the address of a Top Level Domain (TLD) DNS server (such as .com or .net), which stores the information for its domains. When searching for example.com, our request is pointed toward the .com TLD.
  4. The resolver then makes a request to the .com TLD.
  5. The TLD server then responds with the IP address of the domain’s nameserver, example.com.
  6. Lastly, the recursive resolver sends a query to the domain’s nameserver.
  7. The IP address for example.com is then returned to the resolver from the nameserver.
  8. The DNS resolver then responds to the web browser with the IP address of the domain requested initially. Once the 8 steps of the DNS lookup have returned the IP address for example.com, the browser is able to make the request for the web page:

  9. The browser makes a HTTP request to the IP address.
  10. The server at that IP returns the webpage to be rendered in the browser (step 10).

dns_steps

DNS records

  • A – specifies IP addresses corresponding to your domain and its subdomains.
  • MX – specifies where the emails for your domain should be delivered.
  • CNAME – specifies redirects from your domain’s subdomains to other domains/subdomains.
  • TXT – used to store text-based information related to your domain. Most commonly used for storing SPF data.
  • SPF – a mail validation protocol used to prevent email spoofing.
  • AAAA – it maps a domain name to the IP address (IPv6) of the computer hosting the domain.
  • SRV – stands for Service Record and it specifies on only an IP but also a port.

A Canonical Name (CNAME) Record is used in the Domain Name System (DNS) to create an alias from one domain name to another domain name. A common example is the www subdomain which is provided as an alias to the root domain name - users accessing “www.example.com” are referred to the root domain (or DNS zone apex) “example.com”.

An A Record maps a hostname to one or more IP addresses, while the CNAME record maps a hostname to another hostname.

eg:-

NAME TYPE VALUE
--------------------------------------------------
old.example.com. CNAME new.example.com.
new.example.com. A 192.162.100.101

records are cached based on ‘time-to-live’

SSL / TLS

A Secure Socket Layer (SSL) certificate is a security protocol which secures data between two computers by using encryption.

Note: Simply put, an SSL certificate is a data file that digitally ties a Cryptographic Key to a server or domain and an organization’s name and location.

when clients want to connect to server

  1. tcp handshake occures : syn , syn/ack, ack
  2. Ssl handshake occurs :
    • client hello
    • server hello
    • pre master secret