Study guide · Ports, protocols and network services
What talks on the network, and on which port
On every company network, dozens of services talk to each other. A PC asks for names, obtains an address, fetches mail, prints and saves to a network drive. To track down faults and configure firewalls correctly, you need to know what each service does and which port it listens on. On this page you look after the network of Kranich, an advertising agency with forty workstations. Afterwards you will know the important ports and protocols, the typical server roles, and the basics of DNS, DHCP, VLANs and VPNs, as CompTIA A+ Core 1 expects. The page is written in our own words and follows the official exam objectives.
Ports, TCP and UDP
An IP address leads you to the right computer. The port leads you to the right service on that computer. A server can offer web pages, mail and files at the same time because each service listens on its own port. Well-known services have fixed default ports.
Underneath, two transport protocols do the work. TCP, the Transmission Control Protocol, first sets up a connection. It does this with the three-way handshake, using the messages SYN, SYN-ACK and ACK. After that, the receiver acknowledges the data. TCP resends lost segments and puts the data back into the correct order. That is why services where nothing may go missing use TCP. Examples are SSH, HTTPS, mail and file shares.
UDP, the User Datagram Protocol, is connectionless. It sends packets without a handshake and without any acknowledgement. That makes it fast and lightweight, but a lost packet stays lost. DHCP, NTP and the simple file transfer protocol TFTP run over UDP. Of the two transport protocols, only UDP can send a broadcast to every device on the network.
The key ports
For the exam and for everyday work, it pays to know the default ports by heart. The diagram groups them by purpose.
A few pairs are easy to mix up. FTP needs two ports. Port 21 carries the control connection with the commands, and port 20 carries the data. SMB is the protocol behind Windows file shares, and an older version was called CIFS. Today a Windows PC speaks SMB directly over TCP port 445. The NetBIOS ports 137 to 139 come from older networks. There, SMB ran over NetBIOS on top of TCP and IP, known as NetBT. These ports are only needed for legacy devices. LDAP on port 389 queries directory services such as Active Directory, that is, users, groups and computers.
Remote access and clear text
With SSH, the Secure Shell, you log in to the command line of a remote computer over an encrypted connection. SSH uses port 22. Its predecessor Telnet on port 23 offers the same command line, but sends every keystroke in clear text, including the password. Anyone who captures the traffic can read the credentials. That is why Telnet should be replaced. To reach the graphical desktop of a Windows computer, you use RDP, the Remote Desktop Protocol, on port 3389.
Telnet is not the only unprotected protocol. In their basic form, FTP and HTTP also send the user name and password unencrypted. The secure counterparts are SSH for the command line, HTTPS for the web, and SFTP or FTPS for files. HTTPS is HTTP with TLS encryption and runs on port 443, while plain HTTP uses port 80.
On the firewall facing the internet, the rule is simple: only open what is really needed. The agency runs a public web server. For that, inbound ports 80 and 443 are enough, and port 80 often just redirects to 443. File sharing with SMB on 445, NetBIOS on 137 to 139 and Remote Desktop on 3389 are popular targets for attackers. They should never be open to the internet.
Email: sending and fetching
For sending, SMTP, the Simple Mail Transfer Protocol, works on port 25. It hands mail to the server and passes it on between mail servers. For fetching mail there are two protocols that behave very differently.
POP3 on port 110 downloads the messages and, by default, deletes them from the server afterwards. IMAP on port 143 leaves the messages on the server. It keeps folders and read status in sync across all devices. Anyone who wants to see the same state on a PC, a tablet and a smartphone needs IMAP.
An older mail program that still fetches unencrypted with POP3 and sends with SMTP needs ports 110 and 25. Today you would use the encrypted variants instead.
DNS: turning names into addresses
DNS, the Domain Name System, translates names such as www.example.com into IP addresses and, if asked, the other way round. It works on port 53. When name resolution fails, it looks as if the whole internet has gone.
A DNS zone holds different record types.
- An A record, A for address, links a name to an IPv4 address.
- An AAAA record links a name to an IPv6 address. One name can have both records.
- A CNAME makes one name an alias of another name.
- An MX record, for mail exchanger, names the mail server that accepts mail for the domain.
- A TXT record holds free text, for example settings that protect against forged senders.
The CNAME saves maintenance work. If www.kranich.com should point to the same machine as server1.kranich.com, you create a CNAME for www that points to server1. If the address of server1 changes later, you only update its A record or AAAA record. The name www follows automatically.
When a domain has several MX records, the priority decides. The lower number wins. With priority 10 for mail1 and 20 for mail2, other servers deliver to mail1 first. Only when mail1 cannot be reached does mail2 step in. Equal priorities would spread the load.
Stopping forged senders: SPF, DKIM and DMARC
The agency's emails keep landing in customers' spam folders. A common reason is that the domain does not prove who may send on its behalf. Three mechanisms help. All three are published as TXT records in DNS.
- SPF, the Sender Policy Framework, lists the servers that may send mail for the domain.
- DKIM signs outgoing mail. The public key for checking the signature is stored in DNS.
- DMARC sets a policy for what receivers should do with mail that passes neither SPF nor DKIM. Receivers can also send reports back to the domain.
The DMARC policy has three levels. With none, receivers only monitor and report. With quarantine, suspicious mail goes into quarantine or the spam folder. With reject, receivers should refuse such mail outright. Without SPF, DKIM and DMARC, many receivers treat the mail as suspicious. A CNAME or an AAAA record does not help here, because those concern the website.
DHCP: addresses on loan
A DHCP server hands out IP addresses automatically. It only lends each address for a limited time, which is called a lease. Before the lease runs out, the client renews it. If the client does not, the address goes back to the server.
The very first request has a chicken-and-egg problem. The client has no address yet and does not know the server. So it calls out to the whole network with a broadcast. TCP would need a connection to a known address, which is why DHCP uses UDP. The server listens on port 67 and the client on port 68.
The scope defines which addresses the server may lend. It runs from a start address to an end address and belongs to one subnet. Two tools control which device gets which address from it.
- A reservation ties a specific address to a device's MAC address. The network printer stays a DHCP client but always gets the same address.
- An exclusion removes addresses from the scope. DHCP never hands them out. That is where you can set up servers with fixed addresses by hand, without risking duplicate addresses.
In the guest Wi-Fi of a café, the addresses run out every afternoon, even though there are rarely more than fifty guests at once. The lease is too long. The addresses of guests who left hours ago stay taken. A much shorter lease frees them sooner. A larger scope in a larger subnet adds extra headroom. Reservations and exclusions, on the other hand, would shrink the free pool even further.
Server roles on the network
Many services run on their own servers or appliances. Each role has a clear job. You already know DNS servers and DHCP servers from the sections above.
- A web server delivers web pages and web applications over HTTP and HTTPS.
- A mail server accepts mail over SMTP, keeps it in the mailboxes and offers it for retrieval over IMAP or POP3.
- A file server offers folders as shares, usually over SMB. Staff map them as network drives, and permissions control who may read or write.
- A print server manages shared printers centrally. It hands the right drivers to clients and shows all print queues in one place, where you can pause or delete jobs.
- A database server stores structured data centrally and answers queries from several applications, for example with SQL. If the shop, accounting and customer service all need the same customer data, this is the right role.
- An NTP server provides the exact time that clients, servers and network devices follow.
- A syslog server collects event and error messages from servers and network devices in one place.
Syslog and NTP belong together. If the agency wants to analyse the messages from all switches and the firewall together, the syslog server collects them. Only when every device has the same time through NTP can you trace an incident across several devices in the right order. Matching clocks are also needed for logins.
An AAA server has three jobs. Authentication checks who is logging in. Authorization decides what that user may do. Accounting records who used what. Typical AAA servers speak RADIUS or TACACS plus. On a company Wi-Fi network with WPA2 or WPA3 Enterprise, the access point asks the RADIUS server. Everyone logs in with their own account, every login is recorded, and there is no shared Wi-Fi password any more.
Protection and load balancing
A proxy server sits between the clients and the internet. It fetches web pages on their behalf. Along the way, it can filter and log requests and keep frequently loaded content in its cache. If the agency wants to block certain categories of websites and record web access, the proxy is the right device.
A spam gateway sits in front of the mail server. It checks incoming mail for spam, phishing and malware. It flags suspicious messages, puts them into quarantine or rejects them.
A UTM appliance, short for unified threat management, combines several protective functions in one box. They include the firewall and intrusion prevention, as well as antivirus, content filtering and often VPN.
A load balancer spreads incoming requests across several identical servers. It constantly checks whether the servers still respond, which is called a health check. A server that has failed no longer receives requests.
VLANs and VPNs
A VLAN, or virtual LAN, splits one physical network into separate logical networks. Devices on the same switch then behave as if they were connected to different switches. This keeps guests, phones and office PCs apart. Each VLAN is its own broadcast domain.
If two switches need to carry several VLANs over a single cable, you configure the connecting port as a trunk. Each frame then carries a tag with the VLAN number, following the IEEE 802.1Q standard. The VLANs still stay separate. Traffic between them needs a router or a layer 3 switch.
A VPN, or virtual private network, builds an encrypted tunnel across a public network. Devices or whole sites can then work as if they were on the internal network.
IoT and legacy systems
IoT stands for Internet of Things. It means everyday devices with a network connection, such as smart thermostats, cameras, speakers and light bulbs that you control with an app. On a company network they bring two typical risks. They often keep running with the factory password. And the manufacturer delivers security updates rarely or not at all.
SCADA stands for supervisory control and data acquisition. Such systems monitor and control industrial plants, such as power stations, waterworks and production lines. They often run for many years and count as legacy systems. Their software can often hardly be updated, because the control software only runs on the old system.
A customer controls a machine from a PC running Windows XP, and the vendor no longer supplies updates. Replacing it is not an option. So the PC is protected in other ways. It goes into an isolated network segment, and only designated stations may access it.
Key points
- TCP sets up a connection with a handshake, acknowledges and resends. UDP sends without acknowledgement.
- FTP uses 20 and 21, SSH 22, Telnet 23, SMTP 25, DNS 53, HTTP 80, POP3 110 and IMAP 143.
- LDAP uses 389, HTTPS 443, SMB 445, Remote Desktop 3389, and DHCP 67 and 68.
- Telnet, FTP and HTTP send passwords in clear text. SSH, SFTP or FTPS, and HTTPS are the secure choices.
- On the internet firewall, SMB, NetBIOS and RDP stay closed.
- POP3 downloads and deletes, IMAP syncs every device, and SMTP sends.
- An A record points to IPv4, AAAA to IPv6, a CNAME is an alias, and MX names the mail server with a priority.
- SPF, DKIM and DMARC are TXT records in DNS that prove genuine senders.
- DHCP lends addresses with a lease. A reservation ties an address to a MAC address, an exclusion removes addresses from the scope.
- Syslog collects messages, NTP keeps clocks in sync, and AAA checks, authorizes and records.
- A trunk carries several VLANs with 802.1Q tags, and a VPN is an encrypted tunnel.
- IoT devices and legacy systems belong in their own isolated segments.
Terms
- Port
- Number through which a service on a computer can be reached.
- TCP
- Connection-oriented transport protocol with acknowledgements and retransmission.
- UDP
- Connectionless transport protocol without acknowledgements.
- SSH
- Encrypted command-line access on port 22.
- RDP
- Protocol for Windows Remote Desktop on port 3389.
- SMB
- Protocol for Windows file shares on port 445.
- LDAP
- Protocol for querying directory services on port 389.
- SMTP
- Protocol for sending mail on port 25.
- IMAP
- Mail retrieval that keeps every device in sync, on port 143.
- POP3
- Mail retrieval that downloads messages, on port 110.
- DNS
- Service that translates names into IP addresses.
- MX record
- DNS record that names the responsible mail server.
- CNAME
- DNS record that makes one name an alias of another.
- SPF
- TXT record listing the servers allowed to send for the domain.
- DKIM
- Signature on outgoing mail, with the public key in DNS.
- DMARC
- Policy for mail that passes neither SPF nor DKIM.
- Lease
- Time-limited assignment of an IP address by DHCP.
- Reservation
- Fixed DHCP address for a specific MAC address.
- AAA
- Authentication, authorization and accounting of access.
- Proxy
- Server that makes web requests on behalf of clients, filters them and caches content.
- Load balancer
- Device that spreads requests across several servers.
- VLAN
- Logically separate network on shared hardware.
- VPN
- Encrypted tunnel across a public network.
- SCADA
- System for monitoring and controlling industrial plants.