← Dashboard

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".

updated Nov 2026·a 10-minute read·Nmap and Wireshark claims checked on their sites

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.

Common ports and a default exposure rule
PortServiceReachable from the internet?Why
22/tcpSSHRestrict to known addresses or a VPNRemote administration; a constant target for password guessing
23/tcpTelnetNoSends everything, passwords included, in clear text
80/tcpHTTPYes, usually redirecting to HTTPSPublic web traffic
443/tcpHTTPSYesPublic web traffic, encrypted
445/tcpSMB file sharingNoMeant for internal file sharing; exposing it to the internet is widely treated as a serious risk
3389/tcpRemote DesktopNo, put it behind a VPNFull interactive access to the machine
3306/tcp, 5432/tcpMySQL, PostgreSQLNoDatabases 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.

Reading the two states you will see most
StateWhat it tells youWhat to do
openA service answered on that portDecide whether it should be reachable from where you scanned
closedThe host answered, but nothing is listeningUsually fine; the host is up
filteredNmap cannot tell, typically because a firewall drops the probesScan from another position to see behind the filter
WATCHScan only what you have permission to scan. The Nmap project states that you may scan 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.

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.

firewall.pyrun: python3 firewall.py
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")
outputwhat it printed
   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.

Display filters to practice on any capture
FilterShows
tcp.flags.syn == 1 && tcp.flags.ack == 0Connection attempts: the first packet of each TCP handshake
tcp.flags.syn == 1 && tcp.flags.ack == 1Servers accepting a connection (SYN/ACK)
tcp.flags.reset == 1Connections refused or torn down abruptly
dnsName 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.

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.

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.

Go deeper

Network security connects to the rest of the field.