cybersecurity / network security
Network Security: Ports, Firewall Rules and Reading Traffic
Which ports should never face the internet, how Nmap describes what it finds, how a firewall decides between allow and deny (with a script you can run), and how to read a packet capture in Wireshark. Also: where the free options stand next to LinkedIn Learning's "IT Security Foundations: Network Security".
Network security comes down to two jobs: deciding which traffic is allowed to reach a machine, and noticing when traffic does something it should not. Everything else, from firewalls to intrusion detection to Wi-Fi hardening, is a refinement of one of those two. This page teaches both with small exercises. You will classify ports by risk, read the states Nmap reports, work out how a rule list treats a packet, and use Wireshark display filters to pick a TCP handshake out of noise. None of it needs special equipment, and the one scan target we point to is explicitly provided for practice.
01 · WHAT IS LISTENING
Which ports should face the internet
A port is an address for a service on a machine, and the first question in any network review is which ports are reachable and whether they need to be. IANA maintains the registry of service names and port numbers. A handful of well-known assignments account for much of what you will meet.
| Port | Service | Reachable from the internet? | Why |
|---|---|---|---|
| 22/tcp | SSH | Restrict to known addresses or a VPN | Remote administration; a constant target for password guessing |
| 23/tcp | Telnet | No | Sends everything, passwords included, in clear text |
| 80/tcp | HTTP | Yes, usually redirecting to HTTPS | Public web traffic |
| 443/tcp | HTTPS | Yes | Public web traffic, encrypted |
| 445/tcp | SMB file sharing | No | Meant for internal file sharing; exposing it to the internet is widely treated as a serious risk |
| 3389/tcp | Remote Desktop | No, put it behind a VPN | Full interactive access to the machine |
| 3306/tcp, 5432/tcp | MySQL, PostgreSQL | No | Databases should be reached by the application server only |
The last column is judgment, not law, and a legitimate service may have a reason to break these defaults. But the table gives you a working habit: when a scan finds a port, you should be able to state why it is open.
02 · SCANNING
What Nmap's port states actually mean
Nmap is the standard free port scanner. According to its reference guide, the simple command nmap <target> scans 1,000 TCP ports on the target. Where older scanners lumped ports into open and closed, Nmap uses six states: open, closed, filtered, unfiltered, open|filtered and closed|filtered. The book stresses that these states describe how Nmap sees the port from where you scan, not a fixed property of the port. A port that shows as open from inside your office may show as filtered from the internet because a firewall sits in between.
| State | What it tells you | What to do |
|---|---|---|
| open | A service answered on that port | Decide whether it should be reachable from where you scanned |
| closed | The host answered, but nothing is listening | Usually fine; the host is up |
| filtered | Nmap cannot tell, typically because a firewall drops the probes | Scan from another position to see behind the filter |
scanme.nmap.org, with Nmap only (no exploits, no denial of service), and asks for no more than a dozen scans against it per day. Scanning networks you do not own or administer can break the law and your provider's rules.- Nmap: Port Scanning Basics ↗The six port states explained, with examples of how the same port looks from different positions.nmap.org
- Nmap: Legal Issues ↗A practical discussion of the legality of scanning, including the scanme.nmap.org permission.nmap.org
- Nmap Network Scanning (the official guide) ↗The full book online, from port scanning basics for novices to low-level packet crafting.nmap.org
03 · FIREWALL LOGIC
First match wins: working out a rule list
A firewall is a list of rules checked in order. The first rule that matches a packet decides its fate, which makes ordering the most common source of mistakes. This script models a small rule list with Python's built-in ipaddress module so you can test your reasoning.
import ipaddress # First matching rule wins; the last rule is the default. RULES = [ ("allow", "10.0.5.0/24", 22), # admin subnet may use SSH ("deny", "0.0.0.0/0", 22), # everyone else may not ("allow", "0.0.0.0/0", 443), # HTTPS from anywhere ("deny", "0.0.0.0/0", None), # default: drop everything else ] def decide(src, port): ip = ipaddress.ip_address(src) for action, net, p in RULES: if ip in ipaddress.ip_network(net) and p in (None, port): return action return "deny" for src, port in [("10.0.5.17", 22), ("203.0.113.9", 22), ("203.0.113.9", 443), ("10.0.6.17", 22)]: print(f"{src:>12}:{port:<4} -> {decide(src, port)}") print(ipaddress.ip_network("10.0.5.0/24").num_addresses, "addresses in 10.0.5.0/24")
10.0.5.17:22 -> allow 203.0.113.9:22 -> deny 203.0.113.9:443 -> allow 10.0.6.17:22 -> deny 256 addresses in 10.0.5.0/24
Two lessons fall out of it. First, a /24 is 256 addresses, so the administrator at 10.0.6.17 is not covered by a rule written for 10.0.5.0/24, which is the kind of off-by-one-subnet mistake that locks people out. Second, swap the first two rules and every SSH connection is denied, including the administrators, because the broad deny now matches first. Try it. The addresses in 203.0.113.0/24 are reserved for documentation, so they are safe to use in examples.
04 · LOOKING AT PACKETS
Finding a handshake in Wireshark
Wireshark shows the actual packets on a network interface or in a saved capture. A busy capture holds thousands of them, so the skill is filtering. Wireshark's display filter language can check for the presence of a protocol or field, the value of a field, or compare fields. Its TCP field reference lists the flag fields you need: tcp.flags.syn, tcp.flags.ack, tcp.flags.fin and tcp.flags.reset.
| Filter | Shows |
|---|---|
tcp.flags.syn == 1 && tcp.flags.ack == 0 | Connection attempts: the first packet of each TCP handshake |
tcp.flags.syn == 1 && tcp.flags.ack == 1 | Servers accepting a connection (SYN/ACK) |
tcp.flags.reset == 1 | Connections refused or torn down abruptly |
dns | Name lookups, which show what a machine is trying to reach |
A normal connection is SYN, then SYN/ACK, then ACK. A scan looks different: one source sending SYNs to many ports, with most answered by resets. Spotting that pattern is the heart of basic network defense. Practice on the Wireshark project's sample captures, which are organized by protocol, rather than on live traffic you are not authorized to capture. The Malware-Traffic-Analysis tutorials provide capture-based exercises written for analysts, though they involve real malware traffic, so open the files only inside Wireshark and never run anything they contain.
- Wireshark User's Guide ↗The official manual, including the chapter on building display filter expressions.wireshark.org
- Wireshark display filter reference: TCP ↗Every TCP field name you can filter on, with its type and the versions that support it.wireshark.org
- Wireshark sample captures ↗Capture files for dozens of protocols, ready to open and filter.wiki.wireshark.org
- Malware-Traffic-Analysis.net tutorials ↗Packet-capture exercises and workshop material on analyzing malicious network traffic with Wireshark.malware-traffic-analysis.net
05 · COURSES
Free courses, and the LinkedIn Learning title people search for
Many visitors reach this page searching for "IT Security Foundations: Network Security". That is a LinkedIn Learning course by Lisa Bock: its page lists 2 hours 43 minutes, beginner level, covering security devices such as firewalls and honeypots, and offers a one-month free trial rather than free access. The free material below covers the same ground. Cisco's Introduction to Cybersecurity is listed as free, six hours, with seven labs. Fortinet's Training Institute offers self-paced courses. Professor Messer's Network+ course is listed as completely free video.
- Cisco: Introduction to Cybersecurity ↗Free, six hours, beginner level, seven labs, self-paced. Threats, defenses and career options.netacad.com
- Fortinet Training Institute ↗Self-paced and instructor-led courses on network security, with certification levels.training.fortinet.com
- Professor Messer: CompTIA Network+ N10-009 videos ↗A free video course on networking fundamentals, which gives you the foundation security work depends on.professormesser.com
- LinkedIn Learning: IT Security Foundations, Network Security ↗The paid course many searches are for. A one-month free trial is offered on the course page.linkedin.com
06 · FAQ
Frequently asked questions
What should I learn first for network security?
Start with how networks work: IP addressing, TCP and UDP, DNS and common ports. Then learn to see traffic in Wireshark and to map hosts with Nmap. Security decisions such as firewall rules only make sense once you can read a packet.
What are the most important network security tools to learn?
Wireshark for reading packets and Nmap for discovering hosts and open ports are the two most widely used free tools. Both have official manuals and, in Nmap's case, a full book online.
Is it legal to use Nmap and Wireshark?
The tools are legal. Using them is legal on networks you own or have permission to test. The Nmap project explicitly permits scanning scanme.nmap.org with Nmap, up to a dozen scans per day. Capturing or scanning other people's networks without permission can break the law.
Do I need a networking background for network security?
You need the basics, and you can learn them as you go. A free networking video course such as Professor Messer's Network+ series, plus Cisco's free introduction, is enough to follow the exercises above.
Can I learn network security for free?
Yes. Nmap and Wireshark are free with official documentation, sample captures are public, Cisco's introductory course is free, and Fortinet offers self-paced training. Paid courses such as LinkedIn Learning's add structure but are not required.