Basic Networking Flashcards
How does a session get established in TCP?
In TCP, this process is known as three-way handshake. It is used to establish a reliable connection between a client and a server:
1. SYN (Synchronize): The client initiates the connection by sending a SYN (synchronize) packet to the server. This packet contains the initial sequence number (ISN), which is a random number used to start the sequence numbers for the segment transmission. The SYN flag is set to 1 to indicate that this is a connection request.
2. SYN-ACK: Upon receiving the SYN packet, the server responds with a SYN-ACK packet. This packet contains the server’s own initial sequence number and an acknowledgment number that is one more than the initial sequence number received from the client. The SYN and ACK flags are set to 1 to indicate that this is a response to the connection request and to acknowledge the client’s SYN packet.
3. ACK: The client receives the SYN-ACK packet and responds with an ACK packet. This acknowledgment packet contains the next sequence number, which is one more than the acknowledgment number received, and the acknowledgment number is set to one more than the server’s initial sequence number. The ACK flag is set to 1 to indicate that this is an acknowledgment for the server’s SYN-ACK packet.
https://youtu.be/LyDqA-dAPW4?si=TaZ9JHfHxxdjK4T6
What is TCP/IP?
Transmission Control Protocol / Internet Protocol is the fundamental suite of protocols that forms the basis for the Internet. It is a compressed version of the OSI model.
TCP/IP specifies how devices exchange data over the internet to one another. It identifies how the data should be broken down, addressed, transmitted, routed and received for sharing.
TCP defines how applications can create communication channels. It manages how a message is broken down into smaller segments and how it should be put back together.
IP defines how to route these packets to make sure it reaches its destination.
What are TCP/IP layers?
Application Layer: Application specific protocols are defined here. HTTP, HTTPS, FTP, SMTP and DNS are at this layer.
Transport Layer: It ensures that data is transferred reliably and efficiently between hosts. Common protocols here are TCP and UDP.
Internet Layer: This layer is responsible for routing packets of data from source to destination across multiple networks. It uses IP protocol to provide an addressing system and makes routing decisions to forward packets toward their destination.
Link Layer: This is the lowest layer of the TCP/IP model, responsible for interfacing with the physical network hardware. Protocols at this layer include Ethernet, ARP (Address resolution protocol) and PPP (Point to point)
What does each layer responsible of in TCP/IP model?
Application Layer: Application specific protocols are defined here. HTTP, HTTPS, FTP, SMTP and DNS are at this layer.
Transport Layer: It provides end-to-end communication. Common protocols here are TCP and UDP.
Internet Layer: This layer is responsible for routing packets of data from source to destination across multiple networks. It uses IP protocol to provide an addressing system and makes routing decisions to forward packets toward their destination.
Link Layer: This is the lowest layer of the TCP/IP model, responsible for interfacing with the physical network hardware. Protocols at this layer include Ethernet, ARP (Address resolution protocol) and PPP (Point to point)
Describe OSI Model
OSI model or Open Systems Interconnection model is a reference model that describes how applications interact over a computer network. It has 7 layers
All : Application Layer
People : Presentation Layer
Seem : Session Layer
To : Transport Layer
Need : Network Layer
Data : Data Link Layer
Processing : Physical Layer
Please : Physical Layer
Do : Data Layer
Not : Network Layer
Throw : Transport Layer
Sausage : Session Layer
Pizza : Presentation Layer
Away : Application Layer
Its primary purpose is educational and even though the layers dont fit real-world use cases perfectly, they are still widely used by networking vendors and cloud providers.
Describe 7 layers of OSI
Please Do Not Throw Sausage Pizza Away
All People Seem To Need Data Processing
Physical Layer: It is responsible for transmitting raw bits of data across a physical connection. (Hubs Fiber etc)
Datalink Layer: It takes the raw bits from the physical layer and organizes them into frames. It ensures that the frames are delivered to the correct destination. The ethernet primarily lives in this layer.
Network Layer: It is responsible for routing data frames across different networks. The IP part of TCP/IP model is a well-known example of this layer. IPv4, IPv6 come here.
Transport Layer: This layer is responsible for end-to-end communication. TCP and UDP live here. Data in this layer called segments.
There are 3 more layers in the OSI model but they are a bit too fine-grained and do not really reflect reality.
Session Layer: This layer control signals between the computers. Establishes, maintains and terminates connections between processes. 3-way handshake of TCP, the ack packets are here.
Presentation Layer: The formatting, encoding, UTF8 characters, encryption, all are here.
Application Layer: SMTP, HTTP, FTP, HTTPS, DNS are here.
So it’s useful to collapse these three layers into one and consider application protocols like HTTP as Layer-7 protocols.
What is DNS?
It stands for Domain Name System. It is the backbone of the internet. It is internet’s directory. It translates human-readable domain names, such as google.com to machine-readable IP addresses.
What happens when you type www.amazon.com in your browser?
When a url is placed, a DNS query is automatically generated by the browser and a packet is sent to our DNS servers, asking what the IP address is amazon.com. A DNS server has a database of all the IPs mapped to domains. If our first DNS server doesn’t have this information, it makes another query to an authoritative DNS server which might have this information and so on, until it finds the IP of the domain.
How does the DNS resolver find the authoritative name server?
Actually this is where DNS gets interesting. There are 3 main levels of authoritative DNS servers: Root name servers, top level domain (TLD) name servers, authoritative name servers.
Root name servers store the IP addresses of the TLD name servers. (Imagine one root server and underneath, .com, .org, .edu, .de, .ch, .uk etc.) There are 13 logical root name servers. (a.root-servers.net, b.root-servers.net, c.root-servers.net etc) Each root name server is assigned an IP to them. But these root name servers can be anywhere in the world with the same IP. This is done with the magic of anycast. It provides one IP being assigned to multiple servers in different locations and you get routed to the closest server to your location.
The TLD servers store the IP addresses of the authoritative name servers for all the domains under them (.com store amazon.com, google.com, org stores wikipedia.org etc)
Authoritative name servers give answer to the DNS queries. This is where we register our domain.
This design makes DNS highly decentralized and robust.
Can you explain a little bit of the lifecycle of a DNS query?
When you type google.com to your browser:
1. Browser at first checks its cache.
2. If it has no answer, it makes an operating system call to try to get the answer. The OS call would likely have its own cache too. If the answer isn’t there, it reaches out to the DNS resolver.
3. The DNS resolver first checks its cache. If it’s not there or if the answer has expired, it asks the root name server.
4. The root name server responds with the list of the .com TLD name servers. Most probably from its cache.
5. The DNS resolver then reaches out to the .com TLD nameserver, and the .com TLD nameserver returns the authoritative nameservers to google.com.
6. And finally, the DNS resolver reaches out to google.com’s authoritative name server, and it returns the IP address of google.com
7. The DNS resolver then returns the IP address to the operating system, and the operating system returns it to the browser.
How to do updates DNS records for a live, high-traffic, production website?
Some of the default TTLs (time to live) are pretty long and not every DNS resolver actually honor those TTLs. There are 2 practical steps we could take:
1. Reduce the TTL before to something like 30 seconds before we change the DNS record.
2. Leave the server running on the old IP addresses for a while.
What is a firewall?
Firewall is a hardware or a software that is used to secure a network by allowing or blocking incoming or outgoing traffic.
List a few common firewall types…
- Packet filtering firewall: Most common type of firewall which analyze packets and let them pass through only if they match the rule set. (Analyze packets mean - checking source IP, destination IP, port numbers and connection protocol) These firewalls dont have the capacity to do packet inspection. These work on network and transport layer of the OSI model.
- Proxy firewall: These work at Layer 7 of OSI model. Packet. It will deal with application level protocols, http https ftp smtp.
- Stateful multi-layer inspection (SMLI) firewalls: They filter packets at the network, transport and application layers.
- Next-Generation Firewall (NGFW): Incorporates features of the traditional firewall along with additional functionalities like application awareness and control, integrated intrusion prevention, and cloud-delivered threat intelligence.
What is a VPN?
Virtual Private Network. It is a secure tunnel across internet, between a VPN client and a VPN server. The traffic is encrypted. The user has a VPN client installed on their machine, then it creates an encrypted tunnel to VPN server and then it reaches out internet, gets the packets, encrypts them and sends them back to the user.
What do you mean by ipconfig and ifconfig?
ipconfig -> Windows
ifconfig -> linux
These commands are used to view all the adapters and the configuration of all the adapters for their network interfaces.