Networking · Lesson 5 of 14
IP addresses & ports
Understand IPv4 and IPv6 addresses, private vs public IPs, localhost, and network ports like 22, 53, 80 and 443. Practise with interactive IP and port games.
⏱ 15 min🎯 Beginner🧪 Hands-on practice🎬 Video
By the end, you’ll be able to…
- Read an IPv4 address and recognise private, public and loopback ranges
- Explain what a port is and why one device can run many services
- Match common port numbers to the services that use them
Key words
- IPv4
- The classic 32-bit address format, written as four numbers like 192.168.1.10.
- IPv6
- The newer, much larger 128-bit address format, written in hex like 2001:db8::1.
- Private IP
- An address used only inside local networks, such as 192.168.x.x. Not reachable directly from the internet.
- NAT
- Network Address Translation: your router shares one public IP among all your devices.
- Port
- A number (0–65535) that tells a device which program should receive the data.
- Localhost
- Your own computer, usually 127.0.0.1. Traffic to it never leaves the machine.
IP address = which device
An IPv4 address is four numbers from 0 to 255, separated by dots: 192.168.1.23. Each number is 8 bits, so the whole address is 32 bits. That allows about 4.3 billion addresses, which isn’t enough for every device on Earth. So the internet uses two tricks: private addresses and NAT, plus the much bigger IPv6.
Private vs public
Some ranges are reserved for private networks (defined in RFC 1918). Millions of homes reuse them, because they never appear directly on the internet:
| Range | What it is |
|---|---|
10.0.0.0 – 10.255.255.255 | Private (often schools and companies) |
172.16.0.0 – 172.31.255.255 | Private |
192.168.0.0 – 192.168.255.255 | Private (most home routers) |
127.0.0.0 – 127.255.255.255 | Loopback, meaning “this computer”. Usually 127.0.0.1 |
169.254.x.x | Link-local. Often means “DHCP failed, I gave myself an address” |
Your router has one public IP from your ISP and uses NAT to share it with every device at home. That’s why every device in your house appears to websites as the same address.
IPv6
IPv6 addresses are 128 bits, written in hexadecimal: 2001:db8:85a3::8a2e:370:7334. The :: is shorthand for a run of zeros. IPv6 has so many addresses that NAT usually isn’t needed. The IPv6 loopback is ::1.
Port = which program
An IP address gets data to the right device. A port gets it to the right program on that device. Think of the IP as an apartment building’s street address and the port as the apartment number.
A web server listens on port 443 for HTTPS. An SSH server listens on 22. Your browser picks a random high port (like 51544) for its side of the conversation.
| Port | Service | What it’s for |
|---|---|---|
| 22 | SSH | Secure remote terminal |
| 53 | DNS | Name lookups |
| 80 | HTTP | Unencrypted web |
| 443 | HTTPS | Encrypted web |
| 25 | SMTP | Sending email between servers |
| 3389 | RDP | Windows Remote Desktop |
The official list is kept by IANA. Port numbers are conventions, not laws: a server can run SSH on port 2222.
TCP vs UDP
TCP sets up a connection and guarantees delivery. It’s used for web pages and SSH. UDP just sends and hopes, which is faster. It’s used for DNS, video calls and games, where a late packet is useless anyway.
Find your own addresses
# Windows
ipconfig
# macOS
ifconfig # or: ipconfig getifaddr en0
# Linux
ip address
You’ll almost certainly see a private address. Why are security people interested in ports? Every open port is a door into a device. Fewer doors means fewer chances for something to go wrong. You’ll check your own doors in the Nmap lesson.
🧪 Hands-on
Practice
Game 1: is this address private, public or loopback?
Game 2: match each port to its service.
🎬 Watch
Video: Computer Networking Course – Network Engineering
Video by freeCodeCamp, hosted on YouTube. It loads only when you press play.
✅ Check yourself
Quick quiz
🔗 Go further
Trustworthy resources
- RFC 1918: Private address space The original standard for private IPv4 ranges.
- IANA port number registry The official list of port assignments.
- Cloudflare: What is my IP address? Public vs private IPs explained.