TCP/IP Model and Common Ports
Review the OSI and TCP/IP models, well-known port numbers, and how understanding normal traffic helps you spot anomalies.
TCP/IP Model and Common Ports is a free Cloud & IT Cert Prep lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cloud & IT Cert Prep learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The OSI Model: Seven Layers
The OSI (Open Systems Interconnection) model divides network communication into seven layers: Physical, Data Link, Network, Transport, Session, Presentation, and Application. Each layer serves a distinct purpose and communicates only with the layers directly above and below it. Security controls can be applied at any layer, so understanding the model helps you identify where a given attack or defense operates. The mnemonic Please Do Not Throw Sausage Pizza Away helps you recall the layers from bottom to top.
TCP/IP Model vs OSI Model
The TCP/IP model (also called the DoD model) condenses the OSI layers into four: Network Access (OSI layers 1-2), Internet (OSI layer 3), Transport (OSI layer 4), and Application (OSI layers 5-7). Most real-world networking and security analysis uses TCP/IP terminology. Understanding the mapping between both models is essential for Security+ because exam questions may reference either one when describing where an attack or control operates.
# OSI to TCP/IP layer mapping:
# Application (OSI 5,6,7) -> Application (TCP/IP)
# Transport (OSI 4) -> Transport (TCP/IP)
# Network (OSI 3) -> Internet (TCP/IP)
# Data Link, Physical (OSI 1,2) -> Network Access (TCP/IP)IP Addressing and Subnets
IP addresses uniquely identify devices on a network. IPv4 uses 32-bit addresses written in dotted-decimal notation (e.g., 192.168.1.10), while IPv6 uses 128-bit addresses. A subnet mask determines which portion of an address identifies the network versus the host. CIDR notation (e.g., /24) expresses the subnet mask compactly. Security professionals use subnets to segment networks and restrict traffic flow between zones of trust.
# Display IP address and routing table on Linux
ip addr show
ip route show
# Check connectivity
ping -c 4 192.168.1.1TCP Three-Way Handshake
Before data is exchanged over TCP, a three-way handshake establishes a connection: the client sends a SYN, the server replies with a SYN-ACK, and the client completes the process with an ACK. Attackers exploit this sequence in SYN flood DoS attacks by sending many SYN packets without completing the handshake, exhausting server resources. Understanding normal handshake behavior helps analysts spot anomalies in packet captures and SIEM logs.
# Capture TCP handshakes with tcpdump
tcpdump -i eth0 'tcp[tcpflags] & (tcp-syn) != 0'
# View established connections
ss -tnp state establishedUDP: Connectionless Transport
UDP (User Datagram Protocol) is a connectionless transport protocol that sends packets without establishing a session first. It is faster but less reliable than TCP because there is no acknowledgment or retransmission. Services like DNS, DHCP, NTP, and SNMP use UDP because low latency matters more than guaranteed delivery. Security implications include UDP-based amplification attacks, where small requests generate large responses that overwhelm victims.
# Common UDP services and ports:
# DNS UDP 53
# DHCP UDP 67/68
# NTP UDP 123
# SNMP UDP 161
# Syslog UDP 514Well-Known Ports: 0-1023
Well-known ports (0-1023) are reserved for common services and assigned by IANA. Memorizing the most important ones is essential for the Security+ exam. Port 22 is SSH, port 443 is HTTPS, port 80 is HTTP, port 25 is SMTP, and port 53 is DNS. Knowing which port a service uses helps analysts distinguish legitimate traffic from attacks and write accurate firewall rules.
# Key well-known ports:
# 20/21 FTP (data/control)
# 22 SSH
# 23 Telnet (insecure)
# 25 SMTP
# 53 DNS
# 80 HTTP
# 110 POP3
# 143 IMAP
# 443 HTTPS
# 3389 RDPRegistered and Dynamic Ports
Registered ports (1024-49151) are used by applications that require a consistent but non-privileged port. Examples include 3389 (RDP), 3306 (MySQL), 1433 (MSSQL), and 8080 (HTTP alternate). Dynamic (ephemeral) ports (49152-65535) are assigned temporarily by the OS to client-side connections. Attackers sometimes run malicious services on high-numbered ports to avoid firewall rules that only block well-known ports.
# Show all listening ports and associated processes
ss -tlnp
# Check which process owns port 3389
ss -tlnp 'sport = :3389'ICMP and Its Security Implications
ICMP (Internet Control Message Protocol) is used for diagnostics and error reporting. The ping command uses ICMP Echo Request/Reply to test reachability. While useful, ICMP can be exploited: ping sweeps discover live hosts, ICMP redirect messages can manipulate routing tables, and covert channels can tunnel data inside ICMP payloads. Many organizations block ICMP at the perimeter while allowing it internally for troubleshooting.
# Ping sweep example (host discovery)
nmap -sn 192.168.1.0/24
# Block ICMP redirects on Linux
echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirectsARP: Resolving IPs to MAC Addresses
ARP (Address Resolution Protocol) maps IP addresses to MAC addresses on a local network segment. When a host wants to send traffic to 192.168.1.1, it broadcasts an ARP request asking 'Who has 192.168.1.1?' and the owner replies with its MAC address. ARP has no authentication, making it vulnerable to ARP spoofing (also called ARP poisoning), where an attacker sends fake ARP replies to redirect traffic through their machine for man-in-the-middle attacks.
# View ARP cache
arp -n
# Dynamic ARP Inspection (DAI) enabled on Cisco switch
# ip arp inspection vlan 10
# Monitor ARP requests with tcpdump
tcpdump -i eth0 arpDNS: Domain Name Resolution
DNS (Domain Name System) translates human-readable hostnames (www.example.com) into IP addresses. A DNS query travels through a hierarchy: the client queries a recursive resolver, which queries root servers, then TLD servers, then authoritative nameservers. Security implications are significant: DNS cache poisoning inserts fake records, DNS tunneling encodes data in queries to exfiltrate data or reach C2 servers, and typosquatting registers lookalike domains to phish users.
# Query DNS records
nslookup example.com
dig example.com A
dig example.com MX
# Check for DNS tunneling indicators
# Look for unusually long subdomain labels or high query volumeReading Traffic with Wireshark and Nmap
Two essential tools for analyzing TCP/IP traffic are Wireshark and Nmap. Wireshark is a packet analyzer that lets you inspect individual frames, filter by protocol, and follow TCP streams to reconstruct sessions. Nmap is a network scanner that identifies live hosts, open ports, running services, and OS versions. Together they give security professionals visibility into what is actually traversing a network, enabling anomaly detection and confirming firewall rules work as intended.
# Nmap scan examples
nmap -sV 192.168.1.0/24 # Version detection
nmap -sS -O 192.168.1.10 # SYN scan + OS detection
nmap -p 22,80,443 192.168.1.0/24 # Specific ports
# Wireshark capture filter examples
# tcp.port == 443
# ip.src == 192.168.1.10Quick Check
Test your understanding of CompTIA Security+ (SY0-701) concepts from this lesson.
Lesson Recap
In this lesson you learned: the OSI and TCP/IP models describe network layers where security controls operate, well-known ports (0-1023) identify common services and must be memorized for the exam, and protocols like ARP, DNS, and ICMP each carry unique security risks including spoofing, cache poisoning, and tunneling. Next up we explore firewalls and how they filter network traffic.
Frequently asked questions
Is the “TCP/IP Model and Common Ports” lesson free?
Yes — the full text of “TCP/IP Model and Common Ports” is free to read here on the web, and the Cloud & IT Cert Prep course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cloud & IT Cert Prep course, upgrade to CoddyKit PRO.
What will I learn in “TCP/IP Model and Common Ports”?
Review the OSI and TCP/IP models, well-known port numbers, and how understanding normal traffic helps you spot anomalies. You practise Cloud & IT Cert Prep with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Cloud & IT Cert Prep?
No prior experience is required. Cloud & IT Cert Prep on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “TCP/IP Model and Common Ports” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Cloud & IT Cert Prep lesson?
Yes. Every Cloud & IT Cert Prep lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- TCP/IP Model and Common Ports
- Firewalls: Packet Filtering vs Next-Gen
- Network Segmentation and VLANs
- Common Network Attacks: DoS, Spoofing, and MITM