Choosing and recognizing transports
On this page
Port 80 is called the web port, but the lab serves the same site on 8080. You need to decide whether a number identifies the service or only suggests where to look. Then you will compare a refused connection with a datagram that gets no answer.
Before you start
Section titled “Before you start”Finish UDP datagrams. Use the starting lab, leaving machine shells and running netlab reset from the VM if needed. Begin with modes off. Open two terminals on laptop. Each listener needs sudo authentication in its own terminal. Stop it with Ctrl+C after sending.
Ask a different port for the same file
Section titled “Ask a different port for the same file”Start sudo tcpdump -n -i eth0 tcp port 8080 in terminal 1. In terminal 2 run curl -sS -i http://10.77.20.80:8080/hello.txt. Curl’s added -i includes the response headers before the file body. You can read the protocol words in those lines without decoding the whole capture.
learner@laptop:~$ sudo tcpdump -n -i eth0 tcp port 8080[sudo] password for learner: tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes08:32:00.404420 IP 10.77.10.10.52542 > 10.77.20.80.8080: Flags [S], seq 3657867438, win 64240, options [mss 1460,sackOK,TS val 3494503594 ecr 0,nop,wscale 10], length 0
08:32:00.404467 IP 10.77.20.80.8080 > 10.77.10.10.52542: Flags [S.], seq 2389984252, ack 3657867439, win 65160, options [mss 1460,sackOK,TS val 847957458 ecr 3494503594,nop,wscale 10], length 0
08:32:00.404474 IP 10.77.10.10.52542 > 10.77.20.80.8080: Flags [.], ack 1, win 63, options [nop,nop,TS val 3494503594 ecr 847957458], length 0
08:32:00.404517 IP 10.77.10.10.52542 > 10.77.20.80.8080: Flags [P.], seq 1:89, ack 1, win 63, options [nop,nop,TS val 3494503594 ecr 847957458], length 88: HTTP: GET /hello.txt HTTP/1.1
08:32:00.404524 IP 10.77.20.80.8080 > 10.77.10.10.52542: Flags [.], ack 89, win 64, options [nop,nop,TS val 847957458 ecr 3494503594], length 0
08:32:00.406975 IP 10.77.20.80.8080 > 10.77.10.10.52542: Flags [P.], seq 1:173, ack 89, win 64, options [nop,nop,TS val 847957460 ecr 3494503594], length 172: HTTP: HTTP/1.0 200 OK
08:32:00.407008 IP 10.77.10.10.52542 > 10.77.20.80.8080: Flags [.], ack 173, win 63, options [nop,nop,TS val 3494503596 ecr 847957460], length 0
08:32:00.407037 IP 10.77.20.80.8080 > 10.77.10.10.52542: Flags [P.], seq 173:189, ack 89, win 64, options [nop,nop,TS val 847957460 ecr 3494503596], length 16: HTTP
08:32:00.407038 IP 10.77.10.10.52542 > 10.77.20.80.8080: Flags [.], ack 189, win 63, options [nop,nop,TS val 3494503596 ecr 847957460], length 0
08:32:00.407065 IP 10.77.20.80.8080 > 10.77.10.10.52542: Flags [F.], seq 189, ack 89, win 64, options [nop,nop,TS val 847957460 ecr 3494503596], length 0
08:32:00.407128 IP 10.77.10.10.52542 > 10.77.20.80.8080: Flags [F.], seq 89, ack 190, win 63, options [nop,nop,TS val 3494503596 ecr 847957460], length 0
08:32:00.407167 IP 10.77.20.80.8080 > 10.77.10.10.52542: Flags [.], ack 90, win 64, options [nop,nop,TS val 847957460 ecr 3494503596], length 0^C12 packets captured
12 packets received by filter
0 packets dropped by kernellearner@laptop:~$ Steps (10)
- Type
sudo tcpdump -n -i eth0 tcp port 8080 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes - The second terminal finished. Return here and press Ctrl+C to stop listening.
- Output:
08:32:00.404420 IP 10.77.10.10.52542 > 10.77.20.80.8080: Flags [S], seq 3657867438, win 64240, options [mss 1460,sackOK,TS val 3494503594 ecr 0,nop,wscale 10], length 0 08:32:00.404467 IP 10.77.20.80.8080 > 10.77.10.10.52542: Flags [S.], seq 2389984252, ack 3657867439, win 65160, options [mss 1460,sackOK,TS val 847957458 ecr 3494503594,nop,wscale 10], length 0 08:32:00.404474 IP 10.77.10.10.52542 > 10.77.20.80.8080: Flags [.], ack 1, win 63, options [nop,nop,TS val 3494503594 ecr 847957458], length 0 08:32:00.404517 IP 10.77.10.10.52542 > 10.77.20.80.8080: Flags [P.], seq 1:89, ack 1, win 63, options [nop,nop,TS val 3494503594 ecr 847957458], length 88: HTTP: GET /hello.txt HTTP/1.1 08:32:00.404524 IP 10.77.20.80.8080 > 10.77.10.10.52542: Flags [.], ack 89, win 64, options [nop,nop,TS val 847957458 ecr 3494503594], length 0 08:32:00.406975 IP 10.77.20.80.8080 > 10.77.10.10.52542: Flags [P.], seq 1:173, ack 89, win 64, options [nop,nop,TS val 847957460 ecr 3494503594], length 172: HTTP: HTTP/1.0 200 OK 08:32:00.407008 IP 10.77.10.10.52542 > 10.77.20.80.8080: Flags [.], ack 173, win 63, options [nop,nop,TS val 3494503596 ecr 847957460], length 0 08:32:00.407037 IP 10.77.20.80.8080 > 10.77.10.10.52542: Flags [P.], seq 173:189, ack 89, win 64, options [nop,nop,TS val 847957460 ecr 3494503596], length 16: HTTP 08:32:00.407038 IP 10.77.10.10.52542 > 10.77.20.80.8080: Flags [.], ack 189, win 63, options [nop,nop,TS val 3494503596 ecr 847957460], length 0 08:32:00.407065 IP 10.77.20.80.8080 > 10.77.10.10.52542: Flags [F.], seq 189, ack 89, win 64, options [nop,nop,TS val 847957460 ecr 3494503596], length 0 08:32:00.407128 IP 10.77.10.10.52542 > 10.77.20.80.8080: Flags [F.], seq 89, ack 190, win 63, options [nop,nop,TS val 3494503596 ecr 847957460], length 0 08:32:00.407167 IP 10.77.20.80.8080 > 10.77.10.10.52542: Flags [.], ack 90, win 64, options [nop,nop,TS val 847957460 ecr 3494503596], length 0 - Press Ctrl + C
- Output:
12 packets captured 12 packets received by filter 0 packets dropped by kernel
learner@laptop:~$ curl -sS -i http://10.77.20.80:8080/hello.txtHTTP/1.0 200 OK
Server: netlab-web/1.0
Date: Sun, 29 Nov 2026 08:32:00 GMT
Content-type: text/plain
Content-Length: 16
Last-Modified: Thu, 19 Nov 2026 00:00:00 GMT
Hello from web.learner@laptop:~$ Steps (3)
- Type
curl -sS -i http://10.77.20.80:8080/hello.txt - Press Enter
- Output:
HTTP/1.0 200 OK Server: netlab-web/1.0 Date: Sun, 29 Nov 2026 08:32:00 GMT Content-type: text/plain Content-Length: 16 Last-Modified: Thu, 19 Nov 2026 00:00:00 GMT Hello from web.
The response starts HTTP/1.0 200 OK. Those words and the returned file show what the server sent. The two programs agree which port to use. A different destination number does not make their messages a different application protocol.
Check the program as well as the number
Section titled “Check the program as well as the number”On web, run sudo ss -tlnp as in the listener lesson. The -p adds the names of the programs that own the sockets. This earlier recording shows python3 behind 80, 443 and 8080. Separate copies of that program run these services. The program name alone does not tell you what each copy serves.
learner@web:~$ sudo ss -tlnp[sudo] password for learner: State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=113,fd=4))
LISTEN 0 5 *:8080 *:* users:(("python3",pid=107,fd=3))
LISTEN 0 5 *:443 *:* users:(("python3",pid=108,fd=3))
LISTEN 0 5 *:80 *:* users:(("python3",pid=106,fd=3))
LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=113,fd=3)) learner@web:~$ Steps (6)
- Type
sudo ss -tlnp - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=113,fd=4)) LISTEN 0 5 *:8080 *:* users:(("python3",pid=107,fd=3)) LISTEN 0 5 *:443 *:* users:(("python3",pid=108,fd=3)) LISTEN 0 5 *:80 *:* users:(("python3",pid=106,fd=3)) LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=113,fd=3))
Use the lab’s service settings and the messages together. A program such as Python can run different code. The same application can also listen on different ports. Even a decoder’s HTTP label may use the port as a hint. Read the message words before deciding which service it is.
Compare a refusal with silence
Section titled “Compare a refusal with silence”A closed TCP port answered with [R.] in Opening and closing TCP connections. Web sent that reset to reject the connection. UDP has no TCP connection to reset. A closed UDP port can instead cause an ICMP port-unreachable error; filtering can also leave a sender without an answer.
Predict: a UDP datagram gets no reply. Does that prove the destination port is closed?
Stop listeners and leave machine shells. From the VM run netlab mode dns on as in UDP datagrams. Enter laptop in two terminals again. Start sudo tcpdump -n -i eth0 udp or icmp in terminal 1. In terminal 2 run echo hi > /dev/udp/10.77.20.80/9999, then echo hi > /dev/udp/10.77.20.53/53.
The /dev/udp/<address>/<port> form is a Bash feature that sends what you echo as one datagram to that destination. It is not an ordinary file you need to create.
learner@laptop:~$ sudo tcpdump -n -i eth0 udp or icmp[sudo] password for learner: tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes08:32:34.830324 IP 10.77.10.10.43162 > 10.77.20.80.9999: UDP, length 3
08:32:34.830382 IP 10.77.20.80 > 10.77.10.10: ICMP 10.77.20.80 udp port 9999 unreachable, length 39
08:32:35.332270 IP 10.77.10.10.59070 > 10.77.20.53.53: domain [length 3 < 12] (invalid)^C3 packets captured
3 packets received by filter
0 packets dropped by kernellearner@laptop:~$ Steps (10)
- Type
sudo tcpdump -n -i eth0 udp or icmp - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes - The second terminal finished. Return here and press Ctrl+C to stop listening.
- Output:
08:32:34.830324 IP 10.77.10.10.43162 > 10.77.20.80.9999: UDP, length 3 08:32:34.830382 IP 10.77.20.80 > 10.77.10.10: ICMP 10.77.20.80 udp port 9999 unreachable, length 39 08:32:35.332270 IP 10.77.10.10.59070 > 10.77.20.53.53: domain [length 3 < 12] (invalid) - Press Ctrl + C
- Output:
3 packets captured 3 packets received by filter 0 packets dropped by kernel
learner@laptop:~$ echo hi > /dev/udp/10.77.20.80/9999learner@laptop:~$ echo hi > /dev/udp/10.77.20.53/53learner@laptop:~$ Steps (4)
- Type
echo hi > /dev/udp/10.77.20.80/9999 - Press Enter
- Type
echo hi > /dev/udp/10.77.20.53/53 - Press Enter
Check your answer
No. Web returns ICMP 10.77.20.80 udp port 9999 unreachable. The lookup service is open, but the short text is not a valid request. Tcpdump reports domain [length 3 < 12] (invalid) and no answer follows in this recording. No reply alone cannot tell you whether a port is open or closed.
| Test | Saw | Proves | Does not prove |
|---|---|---|---|
| Page port | HTTP answer | This request worked | Same service on all ports |
| Closed TCP port | Reset | Attempt rejected | Machine is down |
| Closed UDP port | ICMP error | Host rejects port | All silence means closed |
| Open UDP service | No answer | No reply observed here | Port is closed |
Mistakes to recognize
Section titled “Mistakes to recognize”“Port 443 means secure.” The number does not prove that the programs encrypted their messages or checked who answered. Everyday Application Traffic examines those properties.
“No reply means closed.” The open lookup service did not answer this input. Record what you sent and where you listened before explaining silence.
Good to know
Section titled “Good to know”A security tool that trusts port numbers can miss a service on another port. It can also give the wrong name to a service on a familiar port. Network Scanning and Enumeration returns to recognizing services from evidence. This lesson’s tests stay inside the closed lab.
Try it yourself
Section titled “Try it yourself”The following shapes come from three other cases on phone. Port numbers and application words are hidden. Name each transport before opening the solution.
| Case | Captured row shape |
|---|---|
| A | S, then R. |
| B | One datagram out, one back |
| C | S, S., ., data, then finishes |
After naming the transports, run a listener on phone with sudo tcpdump -n -i eth0 tcp or udp or icmp. In another phone terminal run curl -sS http://10.77.20.80:8081/, then dig +short @10.77.20.54 web.lab.test, then curl -sS http://10.77.20.80:8080/index.html. Stop and compare the row shapes with your answers. These commands reveal the hidden ports after your prediction.
Solution
learner@phone:~$ sudo tcpdump -n -i eth0 tcp or udp or icmp[sudo] password for learner: tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes08:33:09.859001 IP 10.77.10.11.55426 > 10.77.20.80.8081: Flags [S], seq 457592908, win 64240, options [mss 1460,sackOK,TS val 4103749377 ecr 0,nop,wscale 10], length 0
08:33:09.859065 IP 10.77.20.80.8081 > 10.77.10.11.55426: Flags [R.], seq 0, ack 457592909, win 0, length 0
08:33:10.369064 IP 10.77.10.11.34995 > 10.77.20.54.53: 7766+ [1au] A? web.lab.test. (53)
08:33:10.369261 IP 10.77.20.54.53 > 10.77.10.11.34995: 7766*- 1/1/1 A 10.77.20.80 (90)
08:33:10.876573 IP 10.77.10.11.40802 > 10.77.20.80.8080: Flags [S], seq 1421125508, win 64240, options [mss 1460,sackOK,TS val 2015079079 ecr 0,nop,wscale 10], length 0
08:33:10.876627 IP 10.77.20.80.8080 > 10.77.10.11.40802: Flags [S.], seq 4068367807, ack 1421125509, win 65160, options [mss 1460,sackOK,TS val 523698669 ecr 2015079079,nop,wscale 10], length 0
08:33:10.876635 IP 10.77.10.11.40802 > 10.77.20.80.8080: Flags [.], ack 1, win 63, options [nop,nop,TS val 2015079079 ecr 523698669], length 0
08:33:10.876685 IP 10.77.10.11.40802 > 10.77.20.80.8080: Flags [P.], seq 1:90, ack 1, win 63, options [nop,nop,TS val 2015079080 ecr 523698669], length 89: HTTP: GET /index.html HTTP/1.1
08:33:10.876702 IP 10.77.20.80.8080 > 10.77.10.11.40802: Flags [.], ack 90, win 64, options [nop,nop,TS val 523698670 ecr 2015079080], length 0
08:33:10.879369 IP 10.77.20.80.8080 > 10.77.10.11.40802: Flags [P.], seq 1:173, ack 90, win 64, options [nop,nop,TS val 523698672 ecr 2015079080], length 172: HTTP: HTTP/1.0 200 OK
08:33:10.879414 IP 10.77.10.11.40802 > 10.77.20.80.8080: Flags [.], ack 173, win 63, options [nop,nop,TS val 2015079082 ecr 523698672], length 0
08:33:10.879449 IP 10.77.20.80.8080 > 10.77.10.11.40802: Flags [P.], seq 173:444, ack 90, win 64, options [nop,nop,TS val 523698672 ecr 2015079082], length 271: HTTP
08:33:10.879462 IP 10.77.10.11.40802 > 10.77.20.80.8080: Flags [.], ack 444, win 63, options [nop,nop,TS val 2015079082 ecr 523698672], length 0
08:33:10.879502 IP 10.77.20.80.8080 > 10.77.10.11.40802: Flags [F.], seq 444, ack 90, win 64, options [nop,nop,TS val 523698672 ecr 2015079082], length 0
08:33:10.879693 IP 10.77.10.11.40802 > 10.77.20.80.8080: Flags [F.], seq 90, ack 445, win 63, options [nop,nop,TS val 2015079083 ecr 523698672], length 0
08:33:10.879872 IP 10.77.20.80.8080 > 10.77.10.11.40802: Flags [.], ack 91, win 64, options [nop,nop,TS val 523698673 ecr 2015079083], length 0^C16 packets captured
16 packets received by filter
0 packets dropped by kernellearner@phone:~$ Steps (10)
- Type
sudo tcpdump -n -i eth0 tcp or udp or icmp - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes - The second terminal finished. Return here and press Ctrl+C to stop listening.
- Output:
08:33:09.859001 IP 10.77.10.11.55426 > 10.77.20.80.8081: Flags [S], seq 457592908, win 64240, options [mss 1460,sackOK,TS val 4103749377 ecr 0,nop,wscale 10], length 0 08:33:09.859065 IP 10.77.20.80.8081 > 10.77.10.11.55426: Flags [R.], seq 0, ack 457592909, win 0, length 0 08:33:10.369064 IP 10.77.10.11.34995 > 10.77.20.54.53: 7766+ [1au] A? web.lab.test. (53) 08:33:10.369261 IP 10.77.20.54.53 > 10.77.10.11.34995: 7766*- 1/1/1 A 10.77.20.80 (90) 08:33:10.876573 IP 10.77.10.11.40802 > 10.77.20.80.8080: Flags [S], seq 1421125508, win 64240, options [mss 1460,sackOK,TS val 2015079079 ecr 0,nop,wscale 10], length 0 08:33:10.876627 IP 10.77.20.80.8080 > 10.77.10.11.40802: Flags [S.], seq 4068367807, ack 1421125509, win 65160, options [mss 1460,sackOK,TS val 523698669 ecr 2015079079,nop,wscale 10], length 0 08:33:10.876635 IP 10.77.10.11.40802 > 10.77.20.80.8080: Flags [.], ack 1, win 63, options [nop,nop,TS val 2015079079 ecr 523698669], length 0 08:33:10.876685 IP 10.77.10.11.40802 > 10.77.20.80.8080: Flags [P.], seq 1:90, ack 1, win 63, options [nop,nop,TS val 2015079080 ecr 523698669], length 89: HTTP: GET /index.html HTTP/1.1 08:33:10.876702 IP 10.77.20.80.8080 > 10.77.10.11.40802: Flags [.], ack 90, win 64, options [nop,nop,TS val 523698670 ecr 2015079080], length 0 08:33:10.879369 IP 10.77.20.80.8080 > 10.77.10.11.40802: Flags [P.], seq 1:173, ack 90, win 64, options [nop,nop,TS val 523698672 ecr 2015079080], length 172: HTTP: HTTP/1.0 200 OK 08:33:10.879414 IP 10.77.10.11.40802 > 10.77.20.80.8080: Flags [.], ack 173, win 63, options [nop,nop,TS val 2015079082 ecr 523698672], length 0 08:33:10.879449 IP 10.77.20.80.8080 > 10.77.10.11.40802: Flags [P.], seq 173:444, ack 90, win 64, options [nop,nop,TS val 523698672 ecr 2015079082], length 271: HTTP 08:33:10.879462 IP 10.77.10.11.40802 > 10.77.20.80.8080: Flags [.], ack 444, win 63, options [nop,nop,TS val 2015079082 ecr 523698672], length 0 08:33:10.879502 IP 10.77.20.80.8080 > 10.77.10.11.40802: Flags [F.], seq 444, ack 90, win 64, options [nop,nop,TS val 523698672 ecr 2015079082], length 0 08:33:10.879693 IP 10.77.10.11.40802 > 10.77.20.80.8080: Flags [F.], seq 90, ack 445, win 63, options [nop,nop,TS val 2015079083 ecr 523698672], length 0 08:33:10.879872 IP 10.77.20.80.8080 > 10.77.10.11.40802: Flags [.], ack 91, win 64, options [nop,nop,TS val 523698673 ecr 2015079083], length 0 - Press Ctrl + C
- Output:
16 packets captured 16 packets received by filter 0 packets dropped by kernel
learner@phone:~$ curl -sS http://10.77.20.80:8081/curl: (7) Failed to connect to 10.77.20.80 port 8081 after 0 ms: Couldn't connect to serverlearner@phone:~$ dig +short @10.77.20.54 web.lab.test10.77.20.80learner@phone:~$ curl -sS http://10.77.20.80:8080/index.html<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>web.lab.test</title>
</head>
<body>
<h1>web.lab.test</h1>
<p>This page comes from the lab machine web.</p>
<p><a href="hello.txt">hello.txt</a> · <a href="signin.html">Sign in</a></p>
</body>
</html>learner@phone:~$ Steps (9)
- Type
curl -sS http://10.77.20.80:8081/ - Press Enter
- Output:
curl: (7) Failed to connect to 10.77.20.80 port 8081 after 0 ms: Couldn't connect to server - Type
dig +short @10.77.20.54 web.lab.test - Press Enter
- Output:
10.77.20.80 - Type
curl -sS http://10.77.20.80:8080/index.html - Press Enter
- Output:
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>web.lab.test</title> </head> <body> <h1>web.lab.test</h1> <p>This page comes from the lab machine web.</p> <p><a href="hello.txt">hello.txt</a> · <a href="signin.html">Sign in</a></p> </body> </html>
A is refused TCP; B is UDP; C is successful TCP. Recognize the flags and datagram pattern before using application labels. Afterward stop listeners, leave shells, run netlab mode dns off and check status as in UDP datagrams. Client ports and times vary; your number will differ.
- Treat port numbers as hints.
- Combine socket ownership with application messages.
- Distinguish a reported rejection from an unanswered test.
Next, How a home router shares one address (NAT basics) follows rewritten pairs.