2.2 Given a scenario, configure servers to use network infrastructure services.
📘CompTIA Server+ (SK0-005)
Overview
A firewall is a network security device or software that controls incoming and outgoing network traffic based on a set of security rules. Think of it as a gatekeeper for your server or network. Firewalls help protect servers from unauthorized access, attacks, and malware.
Firewalls can be implemented in several ways:
- Hardware Firewall – A physical device placed between your internal network and the Internet.
- Software Firewall – Installed directly on a server or computer to filter traffic.
- Network Firewall – Usually at the edge of a network, controlling traffic between your internal network and external networks.
- Host-based Firewall – Runs on a server to protect that specific server from threats.
Purpose of a Firewall in Servers
- Control Traffic: Firewalls can allow or block traffic based on protocols, IP addresses, or ports.
- Prevent Unauthorized Access: Stops hackers or unauthorized users from connecting to sensitive services.
- Protect Services: Ensures only approved applications (like web servers or email servers) can communicate through the network.
- Monitor Network Activity: Many firewalls can log traffic and alert administrators of suspicious activity.
Example: A server hosting a web application should only allow traffic on port 80 (HTTP) and 443 (HTTPS). A firewall blocks all other ports, preventing unauthorized services from being accessed.
Understanding Ports
In networking, a port is a numerical identifier for a specific type of network service or application on a server. When data reaches a server, the port number tells the server which service should handle the traffic.
Port Basics
- Ports range from 0 to 65535.
- Ports are divided into three ranges:
| Port Range | Type | Purpose |
|---|---|---|
| 0 – 1023 | Well-known ports | Common protocols like HTTP (80), HTTPS (443), FTP (21), SSH (22) |
| 1024 – 49151 | Registered ports | Assigned to specific services or applications, like Microsoft SQL Server (1433) |
| 49152 – 65535 | Dynamic/Private ports | Temporary ports used for client-side connections, like when your server initiates a connection |
Common Ports for Server Services
| Service | Port Number | Protocol |
|---|---|---|
| HTTP | 80 | TCP |
| HTTPS | 443 | TCP |
| SSH | 22 | TCP |
| FTP | 21 | TCP |
| SMTP (email) | 25 | TCP |
| DNS | 53 | TCP/UDP |
| DHCP | 67/68 | UDP |
| RDP | 3389 | TCP |
| SNMP | 161 | UDP |
Note for Exam: You might be asked which port a service uses or how to allow/block it through a firewall.
Firewall Rules
Firewalls operate using rules. A rule is a condition that either allows or blocks traffic. Rules usually include:
- Source IP/Network – Where the traffic is coming from.
- Destination IP/Network – Where the traffic is going.
- Port/Service – Which service or port the rule applies to.
- Action – Allow or Deny.
Example Rule:
- Allow TCP port 80 and 443 from any IP → this allows users to access the web server.
- Deny all other ports from external networks → blocks all other connections for security.
Stateful vs Stateless Firewalls
- Stateful Firewall: Tracks the state of active connections and allows return traffic automatically.
- Stateless Firewall: Checks each packet individually without tracking connection state.
Exam Tip: Most server environments use stateful firewalls because they are smarter and safer for complex services.
Port-Based Firewall Management
- Opening Ports: Needed when a service on your server should be accessible externally.
- Example: Opening TCP port 443 for your HTTPS web server.
- Closing Ports: Blocks services that should not be exposed, reducing attack surface.
- Example: Closing TCP port 21 if you no longer run an FTP server.
- Port Forwarding: Redirects traffic from one port to another, often used in NAT environments.
Practical Server Scenario Example
Imagine a company has a server running multiple services:
- Web server (HTTP/HTTPS) → Ports 80 & 443
- Email server (SMTP/IMAP) → Ports 25 & 143
- Remote server management (SSH) → Port 22
A firewall configuration might:
- Allow inbound TCP 80 & 443 from any IP → public web access
- Allow TCP 22 only from the IT department IP → secure admin access
- Block all other inbound traffic → prevent unauthorized access
This ensures only the required services are exposed and reduces the risk of attacks.
Exam Key Points to Remember
- Firewalls filter traffic based on IP, protocol, and port.
- Ports identify specific services on a server.
- Well-known ports are 0–1023, registered ports are 1024–49151, dynamic ports are 49152–65535.
- Common ports to remember:
- HTTP → 80
- HTTPS → 443
- SSH → 22
- FTP → 21
- SMTP → 25
- Firewall rules have source, destination, port, and action.
- Stateful firewalls track connections; stateless firewalls do not.
- Always open only required ports and close/block unused ports for security.
