Mastering Network Fundamentals: OSI Model, TCP/IP Handshake, DNS & HTTP Explained
This article provides a comprehensive overview of core networking concepts, including the OSI seven-layer model, TCP/IP three-way handshake and four-way termination, DNS resolution process, HTTP request workflow, intra- and inter-subnet data transmission, Linux network configuration, and practical troubleshooting techniques for common connectivity issues.
1. OSI Seven-Layer Model
Application layer : Provides application interfaces such as FTP, Telnet, HTTP, POP3.
Presentation layer : Handles data conversion, encryption, and compression (e.g., JPEG, GIF, ASCII).
Session layer : Manages sessions between hosts.
Transport layer : Ensures reliable end-to-end transmission; protocols TCP (reliable) and UDP (unreliable).
Network layer : Routes packets between source and destination; implements IP routing.
Data link layer : Frames packets for node-to-node transmission; uses MAC addressing.
Physical layer : Transmits bits over the physical medium.
Key characteristics
Each OSI layer has its own set of functions.
Layers are independent yet rely on each other.
Upper layers depend on services provided by lower layers.
2. TCP/IP Three-Way Handshake and Four-Way Termination
Three-Way Handshake
1) Client sends SYN with a random sequence number x and enters SYN_SENT.
2) Server replies with SYN+ACK, acknowledges x+1, chooses its own sequence y, and enters SYN_RCVD.
3) Client sends ACK acknowledging y+1; both sides enter ESTABLISHED and data transfer can begin.
Four-Way Termination
1) Client sends FIN with sequence x, entering FIN_WAIT_1.
2) Server acknowledges with ACK ( x+1), entering CLOSE_WAIT.
3) Server sends its own FIN with sequence y, entering LAST_ACK.
4) Client acknowledges ( y+1) and enters TIME_WAIT; server moves to CLOSED.
3. DNS Resolution Process
1) Browser checks the local /etc/hosts file.
2) If not found, it queries the local DNS cache.
3) If still unresolved, it contacts the configured primary DNS server, which may answer authoritatively or from its cache.
4) If the primary server cannot resolve, it forwards the request to root servers, then to TLD servers, and finally to the authoritative server for the domain.
4. HTTP Request Flow
1) Address resolution : Parse URL into protocol, hostname, port, and path; resolve hostname via DNS.
2) Build HTTP request packet using the parsed information.
3) Encapsulate into a TCP segment and establish a connection (three-way handshake).
4) Client sends the request line and headers.
5) Server responds with a status line, headers, and optional body.
6) Connection may be closed or kept alive using the Connection: Keep-alive header.
5. Same-Subnet Data Transmission
Hosts encapsulate application data into IP packets, then into Ethernet frames using the destination MAC address obtained via an ARP broadcast.
6. Cross-Subnet Data Transmission
When the destination is in a different subnet, the host forwards the packet to its default gateway (router), which routes it based on its routing table until it reaches the target network.
7. Linux Network Configuration
7.1 Configuring a NIC
Edit /etc/sysconfig/network-scripts/ifcfg-eth0 or use the setup utility.
Activate with ifup ens33, deactivate with ifdown ens33, or restart all interfaces via /etc/init.d/network restart.
7.2 Changing Hostname
Temporary: hostname newname Permanent:
echo "newname" > /etc/hostname7.3 Modifying Default Gateway
Check GATEWAY=... in the NIC config file or /etc/sysconfig/network, or use route add default gw 10.0.0.254 and route del default gw 10.0.0.254.
7.4 Adding IP Aliases
A single NIC can hold multiple temporary IP addresses.
8. Identifying Services on Known Ports
Method 1: lsof
[root@qll251 ~]# lsof | grep del
php-fpm 1165 root 3u REG 8,3 0 132492 /tmp/ZCUDnCFFxq (deleted)
... (output omitted)Method 2: netstat -lntup
Use netstat -lntup to list listening services.
9. Network and Service Fault Diagnosis
Typical steps: ping testing, traceroute, telnet to target ports, checking firewall rules, verifying service status, monitoring server load, and confirming DNS configuration.
10. Sample Interview Questions
9.1 Why a LAN host cannot access the Internet?
Check connectivity to the gateway, DNS settings, IP conflicts, ARP issues, and upstream router or ISP problems.
9.2 How to troubleshoot a slow website?
Verify network path, server health, firewall, resource usage, bandwidth limits, and client-side factors.
Summary
OSI seven-layer model
TCP/IP handshake and termination
HTTP workflow
Network troubleshooting for connectivity issues
DNS resolution principles
Linux network configuration commands
Methods to discover services on ports
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
