Introduction: We're tackling PHASE 5: Transport Layer & Ports (CRITICAL). This is where your packets stop being just 'data' and start becoming 'connections.'
Think of a serverโany server, like a web server or a mail serverโas a massive apartment building. The IP address is the street address of that building. If you send a package (data) to the IP address, it gets to the building. But the data needs to go to a specific tenant inside.
The Port Number is the specific apartment number inside that building. It tells the operating system exactly which running application or service the incoming data is meant for.
The Transport Layer is the central nervous system for every application. Without deep knowledge of how it works, you can't truly master:
If you hit a web server at 192.168.1.1, the OS looks at the port. If it's port 80 or 443, it sends the data to the Web Service (like Apache or Nginx). If it's port 22, it sends the data to the SSH Service. Simple,
right?
Scenario: An employee starts a Shadow IT service (like a rogue FTP server) on an unusual port like 2121 to bypass security filters.
The Risk: Because the service isn't on a well-known port, a lazy scanner might miss it. However, it provides a "backdoor" into the network that isn't being monitored.
Defender Action: Using Service Discovery scans to identify what is actually running on Port 2121, rather than assuming it's safe because it's in the Registered range.
The Internet Assigned Numbers Authority (IANA) divides the 65,535 available ports into three distinct ranges. This organization helps keep things neat and predictable across the entire internet.
One-line definition: These ports are permanently reserved for the most common internet services you interact with every day.
Examples: Port 22 (SSH), Port 80 (HTTP), Port 443 (HTTPS), Port 25 (SMTP).
One-line definition: These ports are officially registered with IANA for specific user-level applications or proprietary services.
Examples: Port 3389 (Microsoft RDP), Port 3306 (MySQL Database), Port 8080 (Alternate HTTP).
One-line definition: These are temporary ports used by client applications when initiating an outgoing connection to a server.
google.com (which is listening on Port 443), your
laptop picks a random high port (e.g., 55321) as its source port.Scenario: A pentester is targeting a Windows server.
Vulnerability: The server is running a database management application on a non-standard port.
Attacker's steps:
Defender's steps (Defense in Depth):
One-line definition: Services must bind to a port to put themselves into a listening state, ready to accept incoming connections.
bind()) and requests port 80.
Result: Now, any packet arriving at the server's IP address with a destination port of 80 is handed directly to the web server application.
One-line definition: A socket is the programming interface endpoint defined by the combination of an IP address and a port number (IP:Port).
A connection is uniquely identified by two sockets:
192.168.1.1:80).
10.0.0.5:55321).
The full conversation is tied to this 4-tuple: (Source IP, Source Port, Destination IP, Destination Port).
Scenario: An attacker is trying to understand the target's exposed services.
Vulnerability: A system administrator installed a backup management service, but forgot
to configure it to only bind to the local loopback interface (127.0.0.1). Instead, it bound
to all interfaces (0.0.0.0) on a Registered Port (e.g., 10000).
Attacker's steps:
0.0.0.0:10000, the OS accepts the packet and hands it
to the service. The service responds, revealing its presence.Defender's steps (Prevention via Binding):
127.0.0.1:10000. This means the socket is
only visible locally.netstat -tuln (or
ss -tuln) to explicitly check the Local Address:Port
column. If it shows 0.0.0.0:10000 or [::]:10000, it's publicly accessible.
If it shows 127.0.0.1:10000, it's secure.
0.0.0.0 is public, 127.0.0.1 is private/local).netstat and ss commandsThis website uses cookies to ensure you get the best experience on our website.