CN Quick Reference
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 :-
-
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
-
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).
-
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
-
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 :-
- User types ‘example.com’ into a web browser and the query travels into the Internet and is received by a DNS recursive resolver.
- The resolver then queries a DNS root nameserver (.).
- 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.
- The resolver then makes a request to the .com TLD.
- The TLD server then responds with the IP address of the domain’s nameserver, example.com.
- Lastly, the recursive resolver sends a query to the domain’s nameserver.
- The IP address for example.com is then returned to the resolver from the nameserver.
-
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:
- The browser makes a HTTP request to the IP address.
- The server at that IP returns the webpage to be rendered in the browser (step 10).
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
- tcp handshake occures : syn , syn/ack, ack
- Ssl handshake occurs :
- client hello
- server hello
- pre master secret