Port Fundamentals
What is a Network Port?
A network port is a virtual point where network connections start and end. Ports are identified by numbers ranging from 0 to 65535, with specific ranges serving different purposes:
Port Range |
Description |
0-1023 |
Well-known ports (system ports) |
1024-49151 |
Registered ports |
49152-65535 |
Dynamic/private ports |
Common Port Types
graph TD
A[Port Types] --> B[TCP Ports]
A --> C[UDP Ports]
B --> D[HTTP: 80]
B --> E[HTTPS: 443]
B --> F[SSH: 22]
C --> G[DNS: 53]
C --> H[DHCP: 67/68]
Checking Open Ports
You can use several Linux commands to inspect open ports:
Using netstat
## List all listening ports
sudo netstat -tuln
Using ss
## Show all TCP listening ports
ss -tuln
Using lsof
## List processes using network ports
sudo lsof -i -P -n
Port Scanning and Security
When managing network ports, understanding potential vulnerabilities is crucial. LabEx recommends using tools like nmap
for comprehensive port analysis:
## Basic port scan
nmap localhost
## Scan specific port range
nmap -p 1-100 localhost
Key Concepts
- Ports enable multiple network services on a single IP
- Each service typically uses a specific port
- Proper port management is essential for network security