Reserved and Commonly Allocated Ports
Reserved and Commonly Allocated Ports
Introduction
As you've learned, port numbers are essential in identifying protocols and services
that enable communication between devices. You've also gained familiarity with IP
addresses and their division into three classes.
This reading will delve deeper into the classification of port numbers based on
number ranges, which is similar to the classification of IP addresses. Understanding
these port number ranges is crucial for distinguishing between different sessions
across a network between devices. By exploring the various protocols associated
with each port number, this reading will be a valuable reference for future use.
Port number ranges
You now know that the range of port numbers used globally is from 0 to 65,535,
which is a vast number range. The Internet Assigned Numbers Authority (IANA)
manages these port numbers since they change over time as technology and
protocols evolve. Any changes made to these port numbers require IANA's
permission.
The port numbers are further divided into three ranges, each serving a slightly
different purpose in the network. The classification is important in identifying
different sessions across a network between devices.
The three port number ranges are:
Well-known ports (0 - 1,023) are reserved for specific protocols and
services used by system processes and applications.
Registered ports (1,024 - 49,151) are assigned by IANA for specific services
or protocols and can also be used by user applications.
Dynamic or private ports (49,152 - 65,535) are used by client applications
to connect to servers and are assigned temporarily for the duration of a
session.
Now that you’re more familiar with the different range classifications, let’s explore
each in a little more detail.
Well-known port numbers (0 - 1,023)
Well-known port numbers are reserved for some of the most commonly used and
popular protocols in computer networks. These ports can either transfer verified
data via TCP or unverified data via UDP. They are assigned at the transport layer of
the OSI model or TCP/IP suite and identified at the application layer.
Review the table below for some of the most common well-known ports:
161, 162 TCP\UDP Simple Network Management Protocol (SNMP) Network device
management
443 TCP\UDP HTTP with Secure Sockets Layer (SSL) (HTTPS) Secure web pag
retrieval
500 UDP Internet Security Association and Key Management Protocol Authentication
(ISAKMP) / Internet Key Exchange (IKE)
636 TCP\UDP Lightweight Directory Access Protocol over TLS/SSL (LDAPS Secure authentic
services
For a complete list of all protocols, please review the following resource from IANA:
Service names and port numbers
When using protocol port numbers, the destination port is usually specified as the
initial step in requesting the correct service from the device that provides the
service. If a server can support multiple protocols, the destination port must specify
which protocol it wants to use.
The following diagram illustrates how ports are used to identify services:
To improve the security of data being transmitted over networks, many protocols
now have alternative versions. These alternative versions often involve encryption
using a security protocol to enhance security. One such example is HTTPS, which
uses the Transport Layer Security (TLS) protocol to encrypt data as it moves across
the network. TLS is also used in other protocols to improve their security, with the
letter 'S' added to the end of the original protocol name to signify the use of TLS.
Registered ports (1,024 - 49,151)
Registered ports are assigned by IANA to companies for specific services that they
want to use. These ports are often used in the gaming sector to identify the ports
that need to be opened in home networks to allow games to function.
Examples include port 3074 for the XBOX live network or ports 3,479/80 for the
PlayStation network. These ports have changed as games become less relevant and
new ones emerge on the market. As technology changes, new ports are assigned
and old ones are retired. Some registered ports have been around for a while, such
as SIP and H323 which are video conferencing protocols that use port numbers
1,719, 1,720, 5,060, and 5,061. For SIP, port 5,060 is used for unencrypted data,
while port 5,061 is used for encrypted data.
Dynamic or private ports (49,152 - 65,535)
Dynamic or private ports are essential for communication between protocols using
TCP or UDP. When a computer has multiple web pages open simultaneously,
dynamic ports are used to identify different sessions. Each open web page will be
associated with a different port number, which serves as the source port number for
communication between devices. This is crucial because it allows your computer to
determine which data belongs to which web page, and it is also the number used
for devices to communicate responses.
The following example demonstrates how a client PC and web server use IP
addresses to communicate with each other. In this scenario, the client PC sends a
web service request (HTTP request) to the web server using port number 80. The
client PC also specifies a source port number (port 5000) for the web server to send
its response. This source port number helps the client PC identify which application
and session the data is for.
Conclusion
In summary, devices use different port numbers to manage network traffic. Well-
known ports are for common applications, registered ports for constantly changing
protocols and newer technologies, and dynamic ports for identifying individual
sessions. Engineers manage network traffic by configuring and monitoring data flow
through specific port numbers, assigning them to specific applications or services,
setting up firewall rules, and analyzing network traffic to improve performance.
By managing network traffic effectively, engineers ensure data is transmitted
securely and efficiently, and applications and services are accessible to users.
Exercise: Ports in use
Introduction
Throughout your journey learning about computer networks, you've come across
various protocols and sessions used by devices to communicate with each other.
You’ve learned that one crucial aspect of this communication is port numbers,
which enable devices to identify the protocols and sessions open during a
conversation. But how can you check which conversations and protocols a device is
using?
In this exercise, you will learn how to identify the ports being used on a computer.
This knowledge can help businesses like Sam's Scoops to determine if they have
potentially exposed themselves to any online risks in the future.
Case study
Sam's Scoops has recently connected to the internet and is considering establishing
an online presence. However, Sam needs to ensure that the network is secure and
not vulnerable to online risks before proceeding. As Sam's advisor, your initial task
is to investigate the network's current protocols and conversations to identify
potential risks.
This exercise will guide you through identifying active sessions on Windows devices,
allowing you to begin understanding which protocols are currently in use on a
network.
Instructions
Identifying protocols and sessions on a Windows device
To find the current sessions and protocols in use on a Windows machine, you can
use the command prompt. As you may recall, you used the command prompt
earlier to find your IP address. This application is available in most Windows
operating systems and is commonly used to troubleshoot or solve certain kinds of
Windows issues.
Here's how to open the command prompt and get your current sessions and
protocols:
1. Click on the Windows Start button in the taskbar, typically located at the
bottom of your screen.
2. Type cmd in the search bar and click on the thumbnail for the command
prompt app.
3. An app with a black background will load. Type netstat -a in the black space
and press enter.
4. Wait for 30 seconds to view the sessions that are currently in use.
5. Identify one of the sessions by noting the ports and protocols in use.
The netstat command commonly displays http or https as protocols when
executed. Other protocols will display, depending on the applications currently
running on the system.
Step 3: Click on the thumbnail to open the command prompt. A window with a black
background will load.
Step 4: Type netstat -a in the black space and press enter.
Step 3: The Mac can produce a lot of output, so scroll back to where you typed the
netstat command and directly beneath this you will find the active sessions.
Conclusion
You should now be able to identify different sessions and protocols that are running
on Windows or Macs. This knowledge enables you to check what protocols are
running on your machine and if they are the secure version of the protocol. Try
opening more applications to see what they are using.
Additional resources: Protocols and ports
Congratulations on completing this lesson about protocols and ports! By now, you
have a comprehensive understanding of how ports help identify protocols and
sessions on a network. Additionally, you have gained knowledge about several
network protocols and their varying levels of security.
With your newfound knowledge, you are now equipped to provide valuable advice
to Sam's Scoops on which protocols would be better suited to their future
applications.
Here are some additional resources that may be helpful as references on the topics
covered in this lesson:
Official list of port numbers and protocols
To explore the full official list of port numbers and protocols, visit the Internet
Assigned Numbers Authority. This resource contains a comprehensive list of port
numbers and protocols in addition to what was already covered in this lesson.
HTTP versus HTTPS
HTTP and HTTPS are both very important as they are used on the web pages that
you view. It is a good idea to know when you are on a secure page when passing
data on the internet, and this is a great resource on how HTTPS accomplishes this.
Understanding Network Address Translation (NAT)
Understanding how your home router manages network traffic is essential for
ensuring smooth communication between devices within your network and the
external internet. A fundamental aspect is how your router uses port numbers to
organize different connections or services in your home network. Port numbers are
crucial in distinguishing these services, which becomes especially important when
dealing with limited public IP addresses.
Network Address Translation (NAT) is a technique that allows multiple devices on a
local network to share a single public-facing IP address. When a device within your
home network communicates with the external world, the router translates the
private IP address into the public IP address. This process helps ensure that the
router returns the correct data to the appropriate device within your local network.
As the data is transmitted, the router assigns a unique port number to each
outgoing connection, enabling it to track multiple simultaneous sessions and
maintain the integrity of the communication.
A critical feature of NAT is port forwarding, which allows external devices to access
specific services within your home network. For example, suppose you're hosting a
web server or an online game. In that case, port forwarding enables external users
to reach those services even though they reside behind the router's single public IP
address.
Resources like the Microsoft article Set up a NAT network and Brightwhiz's
Demystifying NAT (Network Address Translation) and Port Forwarding provide in-
depth explanations of how NAT works and efficiently handles port forwarding and
session management. These guides offer valuable insights into how NAT supports
home and small office networks, managing internal communication and access to
external resources.
Conclusion
In this reading, you explored a list of port numbers and protocols, the difference
between HTTP and HTTPS, and how your home router manages the numerous
sessions and ports originating from your home. It is beneficial to use these
resources to broaden your knowledge.
DNS attacks
Introduction
You now know that DNS converts easy-to-read website names into IP addresses to
make navigating the internet more convenient. This is a useful service used by
people across the world, but it's a prime target for cyberattacks precisely because
it's used so much. One attack can cause many disruptions, and an attacker can
even profit from it. Knowing the risks is a good place to start before you can think
about how to mitigate threats.
In this reading, you will learn about the structure of DNS and the four server types
to understand better where the different vulnerabilities lie within DNS. You will also
examine typical DNS attacks so you can identify different attacks on your own
network one day.
DNS server types
As mentioned previously, you can't rely on only one server to look after all DNS
requests worldwide. You need many to deliver the service. One server can't store all
the possible addresses on the internet, so the workload is spread across many
servers playing different roles in collecting and storing information.
There are four types of DNS servers, illustrated in the diagram below, that provide a
structure, each type playing a different role in that structure. There are the
recursive DNS servers, the root domain servers, top-level DNS servers, and the
authoritative DNS servers. The model is hierarchical, so you must start at the top
and work your way down. Or, as in the diagram below, you start on the left and then
work your way from the top down.
Recursive DNS server
First is the recursive server – or resolver –which is usually the DNS server on your
device with its IP address configured either manually or via DHCP. If it receives a
DNS request and it's familiar with it, the recursive resolver can respond with the IP
address straightaway from its memory. If the recursive resolver is unfamiliar with
the IP address, the request must go to the root domain servers.
Root domain servers
There are 13 root domain servers spread across the world; all looked after by a
governing body called the Internet Assigned Numbers Authority (IANA). The root
domain servers' job is to direct queries to the correct location. Again, the root
server could potentially have the answer if it has dealt with the IP recently, but if
not, it will pass the query to the top-level domain servers that are responsible for
that area.
Top-level DNS servers
Top-level servers (TLD) look after large areas and even countries. Domain name
extensions like .com, .co.uk, .net, and .org are all different TLD servers. Again, they
can give the correct location if they have recently received this request. If not, they
will forward the query to the authoritative name servers.
Authoritative DNS servers
These servers hold the specific information the client has been trying to obtain.
Thus it will provide the necessary website name-to-IP-address translation for the
recursive DNS server. These servers are where companies register their names –
known as domains – like Microsoft.com or samsscoops.com. These servers are
spread over hundreds of locations, providing the many DNS servers needed to
support the internet.
As you can note from the descriptions of the four different types of servers,
requesting a name-to-IP-address translation repeats with each server level until the
query has been answered. No further steps are required if the answer lies in the
recursive DNS server. But if it doesn't, it has to be passed along through each type
of server until the answer is returned.
Now, let's move on to learning more about DNS vulnerabilities and the attacks that
go with them.
DNS attacks
The structure of DNS is both its strongest and weakest attribute. In other words,
with so many servers, it's very fast and reliable, and servers can take over from
others if there's a problem. But having so many servers means there are more
opportunities for attacks because protecting all of them at the same time is a near-
impossible task. This is because they are also managed by different groups and
companies. DNS is susceptible to many diverse attack types across its structure,
and here are five of the main types of attacks.
DNS spoofing
This type of attack involves altering DNS records that store the translations between
website names and IP addresses at the DNS resolvers, altering their cache or
memory. This means that someone could be diverted to a site that delivers a virus
or is even spoofing or imitating another site. These are dangerous as you could
input sensitive information like passwords on these spoof sites, handing it to the
attacker.
DNS hijacking
Hijacking is similar to spoofing but redirects DNS queries to a DNS server under the
attacker's control, as depicted in the diagram below. This means they can send
users anywhere they want them to be. For example, a fake banking site that looks
exactly like the original where someone types in their details, which the attacker
can use to gain access to their bank account.
DNS tunneling
This attack hides other protocols inside DNS queries and responses' payload data.
Attackers use this to pass malware or other protocols to take over a server
remotely. Tunneling attacks generally involve hiding something from a firewall by
having one protocol that it sees on the outside but is actually very different inside.
This is like taking an item in its original packaging, replacing it with something else
in the same packaging, and then passing it off as the original.
DNS amplification
This type of attack is aimed at creating a denial of service. In other words, its aim is
to overwhelm a server so it cannot perform its intended job. For DNS, this involves
sending DNS requests with a fake source IP address, meaning the DNS replies go to
a target the attacker has chosen. An attacker could create hundreds of requests,
overwhelming the target. This attack uses publicly available DNS servers.
DNS flood attack
DNS flooding is similar to amplification, but instead of targeting another source
server, the attack overwhelms the DNS server itself by sending thousands of
spoofed DNS requests. This stops any genuine requests from working.
Conclusion
DNS relies on a structure of four different DNS server types to deal with hundreds of
thousands of requests every second from around the world. The first server your
computer uses is the recursive server. This is the one that your machine directly
interacts with. If the recursive server doesn't know the answer to the request, it
passes it through the other three server types until it finds the DNS response it
needs. The strength of this structure is its resilience and availability. While its
weakness is that it is a prime target for attackers because they can target many
users at the same time, using different types of attacks. Learning about DNS
servers and the attacks that can be launched against them is very important.
Network logs
Introduction
By now, you know that information can be collected from a network in different
ways. For example, packet capture and flow analysis are two ways of monitoring a
network. These give you a real-time idea of how data flows in a network. There are
many data points, but this information shouldn't just be monitored; it should also be
recorded. And in this reading, you're going to explore how information from data
points is recorded in network logs, what kind of different types of logs there are,
and how you can search and filter logs.
What is a log file?
Log files are records of events committed to a file in a list format. They can include
all sorts of information about events that happened at a particular time. Every
device on the network creates log files, thus giving you a history of what's been
happening.
Logs typically contain five headed-up areas. They are:
Timestamp –the time of the event.
Log level – how severe or important the event is.
Username– who caused the event.
Service or application – what caused the event.
Event description – what has happened.
Below is an extract from a Windows machine log, telling you that a logoff event
occurred.
Lastly, you can use search and filter commands. Different operating systems will
allow you to search log files using certain commands. For example, the command
grep is a great command as it is supported across many Linux systems and will
allow you to search for patterns within log files. If you're searching for a particular
error or IP address, this can be a very powerful command. Using such a command
requires practice for you to really benefit from the advanced search capabilities and
filtering they can provide. Here is a resource, How to use the Linux grep command,
that can help get you started.
For Windows, findstr is the command to use in the command prompt application.
Examples of using this command can be found in this Microsoft Learn resource
about findstr.
Windows PowerShell is another powerful tool used to filter and search using the
Select-String command. In the example below, Select-String was used to search
for events related to the IP address 192.168.0.111, and PowerShell provided a list.
If you want to examine some more examples you can use this Microsoft Learn
resource about Select-String.
Conclusion
There are many sources of information across the network, and even a small
network like Sam's Scoops has a lot of data because every device is actively
producing data. This data is split into different types of log files, like events in an
operating system or a log of who is accessing a device. Everything is tracked, which
means that if there is a problem, a log file exists to give you a clue as to what might
have gone wrong. While it's great that everything is tracked, it also means that you
have a large volume of data to work with. Luckily, there are tools available to filter
and search the data. Using purpose-built applications that do the work for you is a
great choice, but if you are dealing with a small network like Sam's, then using
search facilities within an application like Notepad, or commands that can perform
the filtering for you is a great choice.