TCP/IP Basics — The Foundation of Linux Networking¶
TCP/IP (Transmission Control Protocol / Internet Protocol) is the standard networking protocol suite used by the Internet and almost every modern computer network. Every Linux server, cloud instance, Kubernetes cluster, container, and web application communicates using TCP/IP. Understanding TCP/IP is essential for Linux administrators, DevOps engineers, Cloud Architects, Network Engineers, and Site Reliability Engineers (SREs).
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand TCP/IP
- Learn how computers communicate
- Understand the TCP/IP protocol suite
- Learn IPv4 and IPv6 basics
- Understand ports and sockets
- Learn the OSI and TCP/IP models
- Understand packets and routing
- Apply networking concepts in production
Prerequisites¶
Complete:
- Module 1 – Linux Fundamentals
- Module 2 – Linux Command Line Essentials
- Module 3 – Text Processing
- Module 4 – File Management
- Module 5 – Users and Groups
- Module 6 – Process Management
- Module 7 – Package Management
Why Learn TCP/IP?¶
Imagine:
- You open a website.
- You connect to a Linux server using SSH.
- You deploy an application to Kubernetes.
- A Docker container communicates with a database.
- Two cloud servers exchange data.
All of these operations rely on TCP/IP.
Without TCP/IP, modern networking would not exist.
What is TCP/IP?¶
TCP/IP stands for:
It is a collection of networking protocols that define how devices communicate across networks.
TCP/IP is used by:
- Internet
- Corporate networks
- Cloud platforms
- Kubernetes
- Docker
- Virtual machines
- IoT devices
Real-World Communication¶
Imagine sending a courier package.
You:
- Write the destination address.
- Pack the contents.
- Hand it to the courier.
The courier:
- Finds the destination.
- Delivers the package.
Networking works similarly.
TCP/IP Architecture¶
The TCP/IP model consists of four layers.
Each layer performs a specific function.
Layer 1 — Application Layer¶
Provides network services to applications.
Examples:
- HTTP
- HTTPS
- SSH
- FTP
- SMTP
- DNS
Example:
Layer 2 — Transport Layer¶
Responsible for:
- Reliable communication
- Error detection
- Flow control
- Port numbers
Protocols:
TCP¶
TCP provides:
- Reliable delivery
- Ordered packets
- Error checking
- Retransmission
- Connection-oriented communication
Examples:
- HTTP
- HTTPS
- SSH
- MySQL
- PostgreSQL
UDP¶
UDP provides:
- Faster communication
- No delivery guarantee
- No retransmission
- Connectionless communication
Examples:
- DNS queries
- Voice calls
- Video streaming
- Online gaming
TCP vs UDP¶
| Feature | TCP | UDP |
|---|---|---|
| Reliable | ✅ | ❌ |
| Connection-Oriented | ✅ | ❌ |
| Error Recovery | ✅ | ❌ |
| Speed | Slower | Faster |
| Ordering | Guaranteed | Not guaranteed |
| Common Uses | SSH, HTTPS, Databases | DNS, Streaming, VoIP |
Layer 3 — Internet Layer¶
Responsible for:
- IP addressing
- Packet routing
- Network communication
Protocol:
Every device receives an IP address.
Example:
Layer 4 — Network Access Layer¶
Responsible for:
- Physical communication
- Ethernet
- Wi-Fi
- MAC addresses
- Frames
Examples:
- Ethernet
- Wireless
- Fiber
OSI Model vs TCP/IP Model¶
| OSI Model | TCP/IP Model |
|---|---|
| Application | Application |
| Presentation | Application |
| Session | Application |
| Transport | Transport |
| Network | Internet |
| Data Link | Network Access |
| Physical | Network Access |
The TCP/IP model is simpler and is the model used in real-world networking.
IP Address¶
An IP address uniquely identifies a device on a network.
Example:
Without an IP address,
devices cannot communicate over IP networks.
IPv4¶
IPv4 uses:
Example:
Maximum addresses:
Approximately
IPv6¶
IPv6 uses:
Example:
Advantages:
- Vast address space
- Better scalability
- Improved routing efficiency
- Built-in support for modern networking features
Public vs Private IP Addresses¶
Private IP ranges:
Public IP addresses are globally routable on the Internet.
Ports¶
A port identifies a specific service running on a device.
Examples:
| Port | Service |
|---|---|
| 22 | SSH |
| 53 | DNS |
| 80 | HTTP |
| 443 | HTTPS |
| 3306 | MySQL |
| 5432 | PostgreSQL |
Socket¶
A socket is a combination of:
Example:
This uniquely identifies a network endpoint.
Packet Flow¶
Three-Way Handshake¶
TCP establishes a connection using a three-step handshake.
Only after the handshake does data transmission begin.
Common Linux Networking Commands¶
Display IP address.
Display routing table.
Test connectivity.
View listening ports.
Real Production Examples¶
Access a Linux server.
Access a web server.
Database connection.
Kubernetes API Server.
Production Perspective¶
TCP/IP powers:
- Linux servers
- Cloud platforms
- Kubernetes
- Docker
- VPNs
- Firewalls
- Web applications
- Databases
- Monitoring systems
- Enterprise networks
Every production workload depends on TCP/IP.
Hands-on Lab¶
Task 1¶
View IP addresses.
Task 2¶
Display routing information.
Task 3¶
View hostname.
Task 4¶
Test Internet connectivity.
Task 5¶
Display listening ports.
Task 6¶
View network interfaces.
Task 7¶
Check the current kernel hostname.
Task 8¶
Display DNS configuration.
Command Deep Dive¶
| Command | Purpose | Production Example |
|---|---|---|
ip addr | View IP addresses | Network troubleshooting |
ip route | Display routing table | Routing verification |
ping | Test connectivity | Connectivity testing |
ss -tuln | View listening ports | Service verification |
hostname | Show system hostname | Server identification |
ip link | View network interfaces | Interface troubleshooting |
Production Troubleshooting Scenario¶
Scenario
A web application cannot connect to a database.
Investigation:
Check network connectivity.
Verify routing.
Verify the database is listening.
Check firewall rules and application configuration if the service is listening but connectivity still fails.
Best Practices¶
- Understand the TCP/IP layers before troubleshooting.
- Use private IP addresses within internal networks.
- Use TCP for reliable communication.
- Use UDP only when low latency is more important than guaranteed delivery.
- Document network ports used by applications.
- Verify connectivity step by step.
Common Mistakes¶
❌ Confusing an IP address with a port number.
✅ Distinguish clearly between an IP address with a port number.
❌ Assuming every application uses TCP.
✅ Verify every application uses TCP instead of assuming it.
❌ Ignoring routing when troubleshooting connectivity.
✅ Always review routing when troubleshooting connectivity.
❌ Forgetting to verify that the destination service is actually listening.
✅ Remember to to verify that the destination service is actually listening.
Interview Questions¶
Beginner¶
- What does TCP/IP stand for?
- What is the difference between TCP and UDP?
- What is an IP address?
- What is a port number?
Intermediate¶
- What is the purpose of the TCP three-way handshake?
- What is the difference between IPv4 and IPv6?
- What is a socket?
- Why is TCP used for SSH but UDP is commonly used for DNS queries?
Architect Level¶
- How would you troubleshoot connectivity between two cloud servers?
- Why is understanding the TCP/IP model important for Kubernetes networking?
- How do TCP/IP concepts influence the design of highly available distributed systems?
Summary¶
In this lesson, you learned:
- TCP/IP fundamentals
- TCP/IP architecture
- TCP vs UDP
- IPv4 and IPv6
- Ports and sockets
- TCP three-way handshake
- Packet flow
- Production networking concepts
TCP/IP is the foundation of modern computer networking. Every Linux server, cloud platform, container, and distributed application relies on TCP/IP for communication. A solid understanding of these concepts is essential for designing, deploying, and troubleshooting production systems.
Key Takeaways¶
- TCP/IP is the standard networking protocol suite.
- TCP provides reliable, connection-oriented communication.
- UDP provides fast, connectionless communication.
- Every networked device requires an IP address.
- Ports identify services running on a host.
- A socket combines an IP address and a port number.
- Understanding TCP/IP is the first step toward mastering Linux networking.
What's Next?¶
IP Configuration — Configuring Network Interfaces in Linux
You'll explore:
- Network interfaces
- Assigning IP addresses
- Static and dynamic (DHCP) configuration
- Viewing and modifying network settings
- The
ipcommand - Interface management
- Production networking best practices
By the end of the next lesson, you'll be able to configure and manage network interfaces on Linux systems.