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:
| Range | Name | Use |
|---|---|---|
| 0–1023 | system ports (“well-known”) | server services, on many systems only with administrator rights |
| 1024–49151 | user ports (“registered”) | registered services of programs |
| 49152–65535 | dynamic ports (“ephemeral”) | source ports of clients, new for every connection |
Ports you should know
| Port | Protocol | Service |
|---|---|---|
| 20, 21 | TCP | FTP |
| 22 | TCP | SSH |
| 23 | TCP | Telnet (unencrypted) |
| 25 | TCP | SMTP (sending e-mail) |
| 53 | UDP and TCP | DNS |
| 67, 68 | UDP | DHCP (server, client) |
| 80 | TCP | HTTP |
| 110 | TCP | POP3 |
| 143 | TCP | IMAP |
| 443 | TCP (and UDP for QUIC) | HTTPS |
| 520, 521 | UDP | RIP, RIPng |
| 179 | TCP | BGP |
| 500 | UDP | IKE (IPsec) |
| 5060 | UDP and TCP | SIP (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:
| Reply | State |
|---|---|
| SYN/ACK | open: a service accepts connections |
| RST | closed: the device is there, but no service listens |
| none | filtered: 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.