Skip to content

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

Linux Mastery → Module 8: Networking → Lesson 1

Difficulty: Beginner → Intermediate

Reading Time: 75 Minutes

Course Progress

Course: Linux Mastery

Module: Networking

Lesson: 1 of 13


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:

Transmission Control Protocol

Internet Protocol

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.

Application


TCP


IP


Network


Destination

TCP/IP Architecture

The TCP/IP model consists of four layers.

Application Layer
Transport Layer
Internet Layer
Network Access Layer

Each layer performs a specific function.


Layer 1 — Application Layer

Provides network services to applications.

Examples:

  • HTTP
  • HTTPS
  • SSH
  • FTP
  • SMTP
  • DNS

Example:

Browser


HTTPS

Layer 2 — Transport Layer

Responsible for:

  • Reliable communication
  • Error detection
  • Flow control
  • Port numbers

Protocols:

TCP

UDP

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:

IP

Every device receives an IP address.

Example:

192.168.1.100

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:

192.168.1.10

Without an IP address,

devices cannot communicate over IP networks.


IPv4

IPv4 uses:

32 bits

Example:

192.168.10.25

Maximum addresses:

Approximately

4.3 Billion

IPv6

IPv6 uses:

128 bits

Example:

2001:db8::10

Advantages:

  • Vast address space
  • Better scalability
  • Improved routing efficiency
  • Built-in support for modern networking features

Public vs Private IP Addresses

Private IP ranges:

10.0.0.0/8
172.16.0.0/12
192.168.0.0/16

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:

IP Address

+

Port Number

Example:

192.168.1.10:22

This uniquely identifies a network endpoint.


Packet Flow

Application
TCP Segment
IP Packet
Ethernet Frame
Network
Destination

Three-Way Handshake

TCP establishes a connection using a three-step handshake.

Client                Server

SYN  ------------->

     <-------------  SYN-ACK

ACK  ------------->

Connection Established

Only after the handshake does data transmission begin.


Common Linux Networking Commands

Display IP address.

ip addr

Display routing table.

ip route

Test connectivity.

ping google.com

View listening ports.

ss -tuln

Real Production Examples

Access a Linux server.

ssh admin@192.168.1.20

Access a web server.

https://example.com

Database connection.

192.168.1.30:5432

Kubernetes API Server.

6443/TCP

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.

ip addr

Task 2

Display routing information.

ip route

Task 3

View hostname.

hostname

Task 4

Test Internet connectivity.

ping google.com

Task 5

Display listening ports.

ss -tuln

Task 6

View network interfaces.

ip link

Task 7

Check the current kernel hostname.

hostnamectl

Task 8

Display DNS configuration.

cat /etc/resolv.conf

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.

ping 192.168.1.50

Verify routing.

ip route

Verify the database is listening.

ss -tuln | grep 5432

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

  1. What does TCP/IP stand for?
  2. What is the difference between TCP and UDP?
  3. What is an IP address?
  4. What is a port number?

Intermediate

  1. What is the purpose of the TCP three-way handshake?
  2. What is the difference between IPv4 and IPv6?
  3. What is a socket?
  4. Why is TCP used for SSH but UDP is commonly used for DNS queries?

Architect Level

  1. How would you troubleshoot connectivity between two cloud servers?
  2. Why is understanding the TCP/IP model important for Kubernetes networking?
  3. 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 ip command
  • 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.