Wiki DE Start in the browser

Wiki › Basics

Ports and services

How ports distinguish programs on a device, which ranges exist according to RFC 6335 and which port numbers you should know.

Layer
4 (Transport)
Standard
RFC 6335, RFC 9293, RFC 768

Address plus port

The IP address brings a packet to the right device, the port to the right program. TCP and UDP each have 65,536 ports (16 bits). A connection is uniquely identified by five values: protocol, source IP, source port, destination IP, destination port. NAT (which replaces address and port) and the firewall (which filters by them) depend on this.

Three ranges

RFC 6335 divides the ports; IANA keeps the registry:

RangeNameUse
0–1023system ports (“well-known”)server services, on many systems only with administrator rights
1024–49151user ports (“registered”)registered services of programs
49152–65535dynamic ports (“ephemeral”)source ports of clients, new for every connection

Ports you should know

PortProtocolService
20, 21TCPFTP
22TCPSSH
23TCPTelnet (unencrypted)
25TCPSMTP (sending e-mail)
53UDP and TCPDNS
67, 68UDPDHCP (server, client)
80TCPHTTP
110TCPPOP3
143TCPIMAP
443TCP (and UDP for QUIC)HTTPS
520, 521UDPRIP, RIPng
179TCPBGP
500UDPIKE (IPsec)
5060UDP and TCPSIP (IP telephony)

Socket: address, port, protocol

A socket is the endpoint of a connection: IP address, port and protocol, e.g. 192.168.1.10:51234/TCP. A TCP connection is uniquely identified by both sockets, i.e. by four values (source address and port, destination address and port). That is why a web server on port 80 can talk to many browsers at the same time: every browser uses a different source port from the dynamic range. netstat shows exactly these pairs.

In leyoNET

The packet list shows source and destination port for every TCP and UDP frame; the filter tcp.port == 80 shows only web traffic. Clients use source ports from 49152, servers reply from the well-known port. In the firewall and for port forwarding (DNAT), services are selected by their ports.

Finding open ports: the network scanner

On PCs, notebooks and servers the network scanner can be installed in the simulation under Programs (also as the command nmap). It finds devices by ARP and ping and sends a SYN to every port:

ReplyState
SYN/ACKopen: a service accepts connections
RSTclosed: the device is there, but no service listens
nonefiltered: usually a firewall drops the packet

In real networks, scan only with permission.

How to do it in leyoNET

The same text as in the app’s help (F1 key).

Network scanner

The network scanner is a program for PC, notebook and server. To install it, open the desktop in the simulation, tab Programs, “Install”. Then there is the tab Network scanner and the command nmap in the Console of end devices.

  • Target: an address (192.168.1.20), a range (192.168.1.10-20) or a network (192.168.1.0/24, at most 256 addresses); IPv6 as an address, a range in the last group (2001:db8::1-20) or from /120
  • Search: In its own network every device shows up by ARP, in other networks by ping. The address map colours every address.
  • TCP ports: The scanner sends a TCP SYN. open = SYN/ACK, closed = RST, filtered = no reply (often a Firewall).
  • UDP ports (protocol “UDP”, nmap -sU): open = reply (e.g. DNS), closed = ICMP “port unreachable”, open or filtered = no reply (many UDP services do not answer an empty datagram).
  • TTL: From the TTL of the reply it estimates how many routers are in between.

Everything shows up in the Packet list. In real networks, scan only with permission.

Practise

  • ★★★★☆ Protocol analysis – Task 3: ARP, DNS and HTTP · 7 goals · Worksheet (German)
  • ★★★☆☆ Protocol analysis – Task 4: network scan · 8 goals · Worksheet (German)
  • ★★★★☆ Protocol analysis – Task 5: checking the firewall from outside · 7 goals · Worksheet (German)

In leyoNET under Tools → Exercise catalogue. Every exercise checks itself.

Standards

  • RFC 6335 – Internet Assigned Numbers Authority (IANA) Procedures for the Management of the Service Name and Transport Protocol Port Number Registry
  • RFC 9293 – Transmission Control Protocol (TCP)
  • RFC 768 – User Datagram Protocol

Read on

Found a mistake or have an idea? Source of this page on GitHub.