How a home router shares one address (NAT basics)
On this page
Private and public addressing left a question open: Internet routers do not carry private addresses, yet homes use them to reach websites. Watch the router replace each client’s address so web sees one outside address.
Before you start
Section titled “Before you start”Finish Choosing and recognizing transports. Stop listeners and leave all machine shells. Begin at the VM prompt with modes off, using netlab reset if earlier settings changed. This experiment enables address sharing only inside the lab. It adds no connection to the Internet.
Turn on address translation
Section titled “Turn on address translation”Run netlab mode nat on at the VM prompt. The tool asks for your Ubuntu password and rebuilds the lab. Run netlab reset, then netlab status: the reset keeps NAT on. The comment after # labels the status check; Bash ignores it. Enter the machines again afterward.
learner@rootvolt:~$ netlab mode nat on[sudo] password for learner: Mode nat is on: router rewrites home addresses to its site address.learner@rootvolt:~$ netlab resetLab is back in its starting state (modes on: nat).learner@rootvolt:~$ netlab status # nat is onLab is up. Modes on: nat. Fault: none.
MACHINE NETWORK ADDRESS DEFAULT ROUTE COMPARED WITH THE START
laptop home 10.77.10.10/24 10.77.10.1 same
phone home 10.77.10.11/24 10.77.10.1 same
router home, site 10.77.10.1/24 10.77.20.1/24 - same
web site 10.77.20.80/24 10.77.20.1 same
Switch sw-home (home): laptop, phone, router
Switch sw-site (site): router, web
Services: web http 80, web https 443, web http 8080, web ssh 22learner@rootvolt:~$ Steps (12)
- Type
netlab mode nat on - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
Mode nat is on: router rewrites home addresses to its site address. - Type
netlab reset - Press Enter
- Output:
Lab is back in its starting state (modes on: nat). - Type
netlab status # nat is on - Press Enter
- Output:
Lab is up. Modes on: nat. Fault: none. MACHINE NETWORK ADDRESS DEFAULT ROUTE COMPARED WITH THE START laptop home 10.77.10.10/24 10.77.10.1 same phone home 10.77.10.11/24 10.77.10.1 same router home, site 10.77.10.1/24 10.77.20.1/24 - same web site 10.77.20.80/24 10.77.20.1 same Switch sw-home (home): laptop, phone, router Switch sw-site (site): router, web Services: web http 80, web https 443, web http 8080, web ssh 22
Network address translation (NAT) replaces addresses as a router forwards traffic between networks. Here the router can replace ports too. Earlier captures kept the original IP addresses. NAT adds this extra job.
The lab uses a private address on both sides of router. At home, a router may use a public address on its outside. You can watch the same kind of address change here, but this lab still has no Internet connection.
Watch both sides with one listener
Section titled “Watch both sides with one listener”In terminal 1 enter router and run sudo tcpdump -n -i any tcp port 80. The option -i any listens on all router interfaces. Read the interface and direction columns: eth0 In arrives from home, while eth1 Out leaves toward site. Return traffic appears as eth1 In then eth0 Out.
Predict: whose IP address will web see as its client?
In terminal 2 stay on the VM. Run netlab shell laptop -- curl -sS --local-port 50000 http://10.77.20.80/hello.txt, then the same command with phone in place of laptop. The words after -- run inside the named machine. Answer sudo if asked.
Curl’s --local-port chooses a client port; it is used here only to make both devices choose the same number. Ordinary clients let the operating system choose. These requests run one after the other, while the router still remembers the earlier translation.
learner@router:~$ sudo tcpdump -n -i any tcp port 80[sudo] password for learner: tcpdump: data link type LINUX_SLL2
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes08:35:04.270521 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [S], seq 1634246268, win 64240, options [mss 1460,sackOK,TS val 1275545625 ecr 0,nop,wscale 10], length 0
08:35:04.270569 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [S], seq 1634246268, win 64240, options [mss 1460,sackOK,TS val 1275545625 ecr 0,nop,wscale 10], length 0
08:35:04.270608 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [S.], seq 1630769456, ack 1634246269, win 65160, options [mss 1460,sackOK,TS val 3158792747 ecr 1275545625,nop,wscale 10], length 0
08:35:04.270611 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [S.], seq 1630769456, ack 1634246269, win 65160, options [mss 1460,sackOK,TS val 3158792747 ecr 1275545625,nop,wscale 10], length 0
08:35:04.270621 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1275545625 ecr 3158792747], length 0
08:35:04.270625 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1275545625 ecr 3158792747], length 0
08:35:04.270685 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1275545625 ecr 3158792747], length 83: HTTP: GET /hello.txt HTTP/1.1
08:35:04.270695 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1275545625 ecr 3158792747], length 83: HTTP: GET /hello.txt HTTP/1.1
08:35:04.270711 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [.], ack 84, win 64, options [nop,nop,TS val 3158792747 ecr 1275545625], length 0
08:35:04.270714 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [.], ack 84, win 64, options [nop,nop,TS val 3158792747 ecr 1275545625], length 0
08:35:04.273190 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 3158792750 ecr 1275545625], length 172: HTTP: HTTP/1.0 200 OK
08:35:04.273209 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 3158792750 ecr 1275545625], length 172: HTTP: HTTP/1.0 200 OK
08:35:04.273239 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0
08:35:04.273243 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0
08:35:04.273290 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 3158792750 ecr 1275545628], length 16: HTTP
08:35:04.273292 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 3158792750 ecr 1275545628], length 16: HTTP
08:35:04.273304 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0
08:35:04.273305 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0
08:35:04.273352 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 3158792750 ecr 1275545628], length 0
08:35:04.273363 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 3158792750 ecr 1275545628], length 0
08:35:04.273367 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0
08:35:04.273379 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0
08:35:04.273407 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [.], ack 85, win 64, options [nop,nop,TS val 3158792750 ecr 1275545628], length 0
08:35:04.273410 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [.], ack 85, win 64, options [nop,nop,TS val 3158792750 ecr 1275545628], length 0
08:35:04.273452 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0
08:35:04.273454 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0
08:35:04.841228 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [S], seq 599654395, win 64240, options [mss 1460,sackOK,TS val 1956460591 ecr 0,nop,wscale 10], length 0
08:35:04.841258 eth1 Out IP 10.77.20.1.1369 > 10.77.20.80.80: Flags [S], seq 599654395, win 64240, options [mss 1460,sackOK,TS val 1956460591 ecr 0,nop,wscale 10], length 0
08:35:04.841306 eth1 In IP 10.77.20.80.80 > 10.77.20.1.1369: Flags [S.], seq 597012669, ack 599654396, win 65160, options [mss 1460,sackOK,TS val 4219507224 ecr 1956460591,nop,wscale 10], length 0
08:35:04.841309 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [S.], seq 597012669, ack 599654396, win 65160, options [mss 1460,sackOK,TS val 4219507224 ecr 1956460591,nop,wscale 10], length 0
08:35:04.841330 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 0
08:35:04.841339 eth1 Out IP 10.77.20.1.1369 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 0
08:35:04.841396 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 83: HTTP: GET /hello.txt HTTP/1.1
08:35:04.841406 eth1 Out IP 10.77.20.1.1369 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 83: HTTP: GET /hello.txt HTTP/1.1
08:35:04.841427 eth1 In IP 10.77.20.80.80 > 10.77.20.1.1369: Flags [.], ack 84, win 64, options [nop,nop,TS val 4219507224 ecr 1956460591], length 0
08:35:04.841429 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [.], ack 84, win 64, options [nop,nop,TS val 4219507224 ecr 1956460591], length 0
08:35:04.842023 eth1 In IP 10.77.20.80.80 > 10.77.20.1.1369: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460591], length 172: HTTP: HTTP/1.0 200 OK
08:35:04.842036 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460591], length 172: HTTP: HTTP/1.0 200 OK
08:35:04.842083 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0
08:35:04.842086 eth1 Out IP 10.77.20.1.1369 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0
08:35:04.842154 eth1 In IP 10.77.20.80.80 > 10.77.20.1.1369: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460592], length 16: HTTP
08:35:04.842165 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460592], length 16: HTTP
08:35:04.842193 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0
08:35:04.842201 eth1 Out IP 10.77.20.1.1369 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0
08:35:04.842256 eth1 In IP 10.77.20.80.80 > 10.77.20.1.1369: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460592], length 0
08:35:04.842256 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0
08:35:04.842269 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460592], length 0
08:35:04.842273 eth1 Out IP 10.77.20.1.1369 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0
08:35:04.842282 eth1 In IP 10.77.20.80.80 > 10.77.20.1.1369: Flags [.], ack 85, win 64, options [nop,nop,TS val 4219507225 ecr 1956460592], length 0
08:35:04.842283 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0
08:35:04.842284 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [.], ack 85, win 64, options [nop,nop,TS val 4219507225 ecr 1956460592], length 0
08:35:04.842295 eth1 Out IP 10.77.20.1.1369 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0^C52 packets captured
52 packets received by filter
0 packets dropped by kernellearner@router:~$ Steps (10)
- Type
sudo tcpdump -n -i any tcp port 80 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
tcpdump: data link type LINUX_SLL2 tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes - The second terminal finished. Return here and press Ctrl+C to stop listening.
- Output:
08:35:04.270521 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [S], seq 1634246268, win 64240, options [mss 1460,sackOK,TS val 1275545625 ecr 0,nop,wscale 10], length 0 08:35:04.270569 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [S], seq 1634246268, win 64240, options [mss 1460,sackOK,TS val 1275545625 ecr 0,nop,wscale 10], length 0 08:35:04.270608 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [S.], seq 1630769456, ack 1634246269, win 65160, options [mss 1460,sackOK,TS val 3158792747 ecr 1275545625,nop,wscale 10], length 0 08:35:04.270611 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [S.], seq 1630769456, ack 1634246269, win 65160, options [mss 1460,sackOK,TS val 3158792747 ecr 1275545625,nop,wscale 10], length 0 08:35:04.270621 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1275545625 ecr 3158792747], length 0 08:35:04.270625 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1275545625 ecr 3158792747], length 0 08:35:04.270685 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1275545625 ecr 3158792747], length 83: HTTP: GET /hello.txt HTTP/1.1 08:35:04.270695 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1275545625 ecr 3158792747], length 83: HTTP: GET /hello.txt HTTP/1.1 08:35:04.270711 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [.], ack 84, win 64, options [nop,nop,TS val 3158792747 ecr 1275545625], length 0 08:35:04.270714 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [.], ack 84, win 64, options [nop,nop,TS val 3158792747 ecr 1275545625], length 0 08:35:04.273190 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 3158792750 ecr 1275545625], length 172: HTTP: HTTP/1.0 200 OK 08:35:04.273209 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 3158792750 ecr 1275545625], length 172: HTTP: HTTP/1.0 200 OK 08:35:04.273239 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0 08:35:04.273243 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0 08:35:04.273290 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 3158792750 ecr 1275545628], length 16: HTTP 08:35:04.273292 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 3158792750 ecr 1275545628], length 16: HTTP 08:35:04.273304 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0 08:35:04.273305 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0 08:35:04.273352 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 3158792750 ecr 1275545628], length 0 08:35:04.273363 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 3158792750 ecr 1275545628], length 0 08:35:04.273367 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0 08:35:04.273379 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0 08:35:04.273407 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [.], ack 85, win 64, options [nop,nop,TS val 3158792750 ecr 1275545628], length 0 08:35:04.273410 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [.], ack 85, win 64, options [nop,nop,TS val 3158792750 ecr 1275545628], length 0 08:35:04.273452 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0 08:35:04.273454 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1275545628 ecr 3158792750], length 0 08:35:04.841228 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [S], seq 599654395, win 64240, options [mss 1460,sackOK,TS val 1956460591 ecr 0,nop,wscale 10], length 0 08:35:04.841258 eth1 Out IP 10.77.20.1.1369 > 10.77.20.80.80: Flags [S], seq 599654395, win 64240, options [mss 1460,sackOK,TS val 1956460591 ecr 0,nop,wscale 10], length 0 08:35:04.841306 eth1 In IP 10.77.20.80.80 > 10.77.20.1.1369: Flags [S.], seq 597012669, ack 599654396, win 65160, options [mss 1460,sackOK,TS val 4219507224 ecr 1956460591,nop,wscale 10], length 0 08:35:04.841309 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [S.], seq 597012669, ack 599654396, win 65160, options [mss 1460,sackOK,TS val 4219507224 ecr 1956460591,nop,wscale 10], length 0 08:35:04.841330 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 0 08:35:04.841339 eth1 Out IP 10.77.20.1.1369 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 0 08:35:04.841396 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 83: HTTP: GET /hello.txt HTTP/1.1 08:35:04.841406 eth1 Out IP 10.77.20.1.1369 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 83: HTTP: GET /hello.txt HTTP/1.1 08:35:04.841427 eth1 In IP 10.77.20.80.80 > 10.77.20.1.1369: Flags [.], ack 84, win 64, options [nop,nop,TS val 4219507224 ecr 1956460591], length 0 08:35:04.841429 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [.], ack 84, win 64, options [nop,nop,TS val 4219507224 ecr 1956460591], length 0 08:35:04.842023 eth1 In IP 10.77.20.80.80 > 10.77.20.1.1369: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460591], length 172: HTTP: HTTP/1.0 200 OK 08:35:04.842036 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460591], length 172: HTTP: HTTP/1.0 200 OK 08:35:04.842083 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0 08:35:04.842086 eth1 Out IP 10.77.20.1.1369 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0 08:35:04.842154 eth1 In IP 10.77.20.80.80 > 10.77.20.1.1369: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460592], length 16: HTTP 08:35:04.842165 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460592], length 16: HTTP 08:35:04.842193 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0 08:35:04.842201 eth1 Out IP 10.77.20.1.1369 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0 08:35:04.842256 eth1 In IP 10.77.20.80.80 > 10.77.20.1.1369: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460592], length 0 08:35:04.842256 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0 08:35:04.842269 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460592], length 0 08:35:04.842273 eth1 Out IP 10.77.20.1.1369 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0 08:35:04.842282 eth1 In IP 10.77.20.80.80 > 10.77.20.1.1369: Flags [.], ack 85, win 64, options [nop,nop,TS val 4219507225 ecr 1956460592], length 0 08:35:04.842283 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0 08:35:04.842284 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [.], ack 85, win 64, options [nop,nop,TS val 4219507225 ecr 1956460592], length 0 08:35:04.842295 eth1 Out IP 10.77.20.1.1369 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1956460592 ecr 4219507225], length 0 - Press Ctrl + C
- Output:
52 packets captured 52 packets received by filter 0 packets dropped by kernel
learner@rootvolt:~$ netlab shell laptop -- curl -sS --local-port 50000 http://10.77.20.80/hello.txt[sudo] password for learner: Hello from web.learner@rootvolt:~$ netlab shell phone -- curl -sS --local-port 50000 http://10.77.20.80/hello.txtHello from web.learner@rootvolt:~$ Steps (9)
- Type
netlab shell laptop -- curl -sS --local-port 50000 http://10.77.20.80/hello.txt - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
Hello from web. - Type
netlab shell phone -- curl -sS --local-port 50000 http://10.77.20.80/hello.txt - Press Enter
- Output:
Hello from web.
Check your answer
Web sees router’s site address, 10.77.20.1, rather than either home client address. The eth1 Out lines show exactly the pairs sent toward web. You read these pairs on router’s site link.
Keep the two clients separate
Section titled “Keep the two clients separate”Laptop starts as 10.77.10.10:50000. Router replaces the source address and keeps that port because it is free. Phone starts as 10.77.10.11:50000. Router gives phone a different outside port because it still remembers laptop’s use of that pair.
| Device | Inside address and port | Outside address and port |
|---|---|---|
| laptop | 10.77.10.10:50000 |
10.77.20.1:50000 |
| phone | 10.77.10.11:50000 |
10.77.20.1:1369 |
Router remembers which inside pair belongs to each outside pair. The table shows the pairs you can read in the capture. It does not show router’s internal records. The rewritten phone port belongs to this run; your number will differ.
Rewrite phone’s outgoing pair
- phonemachine
- routerrouter
- webserver
In the capture4 capture points
- phone:eth0
08:35:04.841387 02:77:10:00:00:11 > 02:77:10:00:00:01, ethertype IPv4 (0x0800), length 149: 10.77.10.11.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 83: HTTP: GET /hello.txt HTTP/1.1 - router:eth0
08:35:04.841397 02:77:10:00:00:11 > 02:77:10:00:00:01, ethertype IPv4 (0x0800), length 149: 10.77.10.11.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 83: HTTP: GET /hello.txt HTTP/1.1 - router:eth1
08:35:04.841406 02:77:20:00:00:01 > 02:77:20:00:00:80, ethertype IPv4 (0x0800), length 149: 10.77.20.1.1369 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 83: HTTP: GET /hello.txt HTTP/1.1 - web:eth0
08:35:04.841415 02:77:20:00:00:01 > 02:77:20:00:00:80, ethertype IPv4 (0x0800), length 149: 10.77.20.1.1369 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 83: HTTP: GET /hello.txt HTTP/1.1
netlab shell phone -- curl -sS --local-port 50000 http://10.77.20.80/hello.txt, on Ubuntu 24.04.5 LTS, netlab 1.0, tcpdump 4.99.4. The values are the capture's; what each device reads is the model. Phone's captured request crosses home and site with its source address and port changed at router's outgoing step, and switches omitted.Steps (4)
- Send. Phone sends from its inside address and chosen client port.
08:35:04.841387 02:77:10:00:00:11 > 02:77:10:00:00:01, ethertype IPv4 (0x0800), length 149: 10.77.10.11.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 83: HTTP: GET /hello.txt HTTP/1.1 - Router in. Router receives the original client pair on home. Read: Source address and Source port.
08:35:04.841397 02:77:10:00:00:11 > 02:77:10:00:00:01, ethertype IPv4 (0x0800), length 149: 10.77.10.11.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 83: HTTP: GET /hello.txt HTTP/1.1 - Router out. Router replaces the source address and port with the outside pair. Rewritten: Source address 10.77.10.11 to 10.77.20.1 and Source port 50000 to 1369.
08:35:04.841406 02:77:20:00:00:01 > 02:77:20:00:00:80, ethertype IPv4 (0x0800), length 149: 10.77.20.1.1369 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 83: HTTP: GET /hello.txt HTTP/1.1 - Receive. Web receives a packet naming router’s site address as its client. Read: Source address and Source port.
08:35:04.841415 02:77:20:00:00:01 > 02:77:20:00:00:80, ethertype IPv4 (0x0800), length 149: 10.77.20.1.1369 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1956460591 ecr 4219507224], length 83: HTTP: GET /hello.txt HTTP/1.1
The journey follows the same packet at phone, both router interfaces and web. A field glows where its value changes. Laptop keeps its port, so NAT need not change every source port.
Send the answer back to its owner
Section titled “Send the answer back to its owner”Web sends its answer to the outside pair it saw. Router looks up the inside pair and replaces the answer’s destination address and port. Phone receives the answer at its original pair.
Return to the original client
- webserver
- routerrouter
- phonemachine
In the capture4 capture points
- web:eth0
08:35:04.842004 02:77:20:00:00:80 > 02:77:20:00:00:01, ethertype IPv4 (0x0800), length 238: 10.77.20.80.80 > 10.77.20.1.1369: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460591], length 172: HTTP: HTTP/1.0 200 OK - router:eth1
08:35:04.842024 02:77:20:00:00:80 > 02:77:20:00:00:01, ethertype IPv4 (0x0800), length 238: 10.77.20.80.80 > 10.77.20.1.1369: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460591], length 172: HTTP: HTTP/1.0 200 OK - router:eth0
08:35:04.842037 02:77:10:00:00:01 > 02:77:10:00:00:11, ethertype IPv4 (0x0800), length 238: 10.77.20.80.80 > 10.77.10.11.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460591], length 172: HTTP: HTTP/1.0 200 OK - phone:eth0
08:35:04.842047 02:77:10:00:00:01 > 02:77:10:00:00:11, ethertype IPv4 (0x0800), length 238: 10.77.20.80.80 > 10.77.10.11.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460591], length 172: HTTP: HTTP/1.0 200 OK
netlab shell phone -- curl -sS --local-port 50000 http://10.77.20.80/hello.txt, on Ubuntu 24.04.5 LTS, netlab 1.0, tcpdump 4.99.4. The values are the capture's; what each device reads is the model. The captured answer reverses the translation: router restores phone's destination address and chosen port on home.Steps (4)
- Send. Web answers the outside address and port it saw.
08:35:04.842004 02:77:20:00:00:80 > 02:77:20:00:00:01, ethertype IPv4 (0x0800), length 238: 10.77.20.80.80 > 10.77.20.1.1369: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460591], length 172: HTTP: HTTP/1.0 200 OK - Router in. Router receives the reply addressed to its site pair. Read: Destination address and Destination port.
08:35:04.842024 02:77:20:00:00:80 > 02:77:20:00:00:01, ethertype IPv4 (0x0800), length 238: 10.77.20.80.80 > 10.77.20.1.1369: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460591], length 172: HTTP: HTTP/1.0 200 OK - Router out. The stored translation restores phone’s original destination address and port. Rewritten: Destination address 10.77.20.1 to 10.77.10.11 and Destination port 1369 to 50000.
08:35:04.842037 02:77:10:00:00:01 > 02:77:10:00:00:11, ethertype IPv4 (0x0800), length 238: 10.77.20.80.80 > 10.77.10.11.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460591], length 172: HTTP: HTTP/1.0 200 OK - Receive. Phone receives the answer at its chosen client port. Read: Destination address and Destination port.
08:35:04.842047 02:77:10:00:00:01 > 02:77:10:00:00:11, ethertype IPv4 (0x0800), length 238: 10.77.20.80.80 > 10.77.10.11.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 4219507225 ecr 1956460591], length 172: HTTP: HTTP/1.0 200 OK
Mistakes to recognize
Section titled “Mistakes to recognize”“NAT is what routers do.” Routing chooses the next network. Address translation is an extra function enabled here; the earlier lab routed without it.
“NAT is a firewall.” Translation is not an access rule. Hiding an inside address does not make a device safe or decide which traffic should be allowed.
Good to know
Section titled “Good to know”An outside observer sees router’s address and can still see that someone is communicating. NAT and Stateful Firewalls explains port forwarding and stateful filtering later. Changing an address does not decide which messages are allowed through.
Try it yourself
Section titled “Try it yourself”Reverse the order: phone first, then laptop, both choosing port 50000. Predict which device’s port router changes. Write the pairs you expect on site and home for that device’s answer.
Stop listeners and leave machine shells. Run netlab reset from the VM to clear the earlier translations; NAT stays on. Start the same router listener again. In a second VM terminal run netlab shell phone -- curl -sS --local-port 50000 http://10.77.20.80/hello.txt, then the command with laptop instead of phone. Stop the listener and compare both sides of the answer with your prediction.
Solution
learner@router:~$ sudo tcpdump -n -i any tcp port 80[sudo] password for learner: tcpdump: data link type LINUX_SLL2
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes08:52:07.566026 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [S], seq 3694827773, win 64240, options [mss 1460,sackOK,TS val 1957483384 ecr 0,nop,wscale 10], length 0
08:52:07.566070 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [S], seq 3694827773, win 64240, options [mss 1460,sackOK,TS val 1957483384 ecr 0,nop,wscale 10], length 0
08:52:07.566094 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [S.], seq 439892248, ack 3694827774, win 65160, options [mss 1460,sackOK,TS val 3159816111 ecr 1957483384,nop,wscale 10], length 0
08:52:07.566096 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [S.], seq 439892248, ack 3694827774, win 65160, options [mss 1460,sackOK,TS val 3159816111 ecr 1957483384,nop,wscale 10], length 0
08:52:07.566105 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1957483384 ecr 3159816111], length 0
08:52:07.566107 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1957483384 ecr 3159816111], length 0
08:52:07.566159 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1957483384 ecr 3159816111], length 83: HTTP: GET /hello.txt HTTP/1.1
08:52:07.566174 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1957483384 ecr 3159816111], length 83: HTTP: GET /hello.txt HTTP/1.1
08:52:07.566180 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [.], ack 84, win 64, options [nop,nop,TS val 3159816111 ecr 1957483384], length 0
08:52:07.566181 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [.], ack 84, win 64, options [nop,nop,TS val 3159816111 ecr 1957483384], length 0
08:52:07.568907 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 3159816114 ecr 1957483384], length 172: HTTP: HTTP/1.0 200 OK
08:52:07.568945 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 3159816114 ecr 1957483384], length 172: HTTP: HTTP/1.0 200 OK
08:52:07.568993 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0
08:52:07.568998 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0
08:52:07.569037 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 3159816114 ecr 1957483387], length 16: HTTP
08:52:07.569049 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 3159816114 ecr 1957483387], length 16: HTTP
08:52:07.569063 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0
08:52:07.569064 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0
08:52:07.569100 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 3159816114 ecr 1957483387], length 0
08:52:07.569111 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 3159816114 ecr 1957483387], length 0
08:52:07.569119 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0
08:52:07.569131 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0
08:52:07.569140 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [.], ack 85, win 64, options [nop,nop,TS val 3159816114 ecr 1957483387], length 0
08:52:07.569143 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [.], ack 85, win 64, options [nop,nop,TS val 3159816114 ecr 1957483387], length 0
08:52:07.569186 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0
08:52:07.569198 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0
08:52:08.155315 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [S], seq 452574860, win 64240, options [mss 1460,sackOK,TS val 1276569579 ecr 0,nop,wscale 10], length 0
08:52:08.155494 eth1 Out IP 10.77.20.1.10634 > 10.77.20.80.80: Flags [S], seq 452574860, win 64240, options [mss 1460,sackOK,TS val 1276569579 ecr 0,nop,wscale 10], length 0
08:52:08.155579 eth1 In IP 10.77.20.80.80 > 10.77.20.1.10634: Flags [S.], seq 2503747844, ack 452574861, win 65160, options [mss 1460,sackOK,TS val 3088975262 ecr 1276569579,nop,wscale 10], length 0
08:52:08.155588 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [S.], seq 2503747844, ack 452574861, win 65160, options [mss 1460,sackOK,TS val 3088975262 ecr 1276569579,nop,wscale 10], length 0
08:52:08.155639 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1276569580 ecr 3088975262], length 0
08:52:08.155646 eth1 Out IP 10.77.20.1.10634 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1276569580 ecr 3088975262], length 0
08:52:08.155778 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1276569580 ecr 3088975262], length 83: HTTP: GET /hello.txt HTTP/1.1
08:52:08.155798 eth1 Out IP 10.77.20.1.10634 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1276569580 ecr 3088975262], length 83: HTTP: GET /hello.txt HTTP/1.1
08:52:08.155824 eth1 In IP 10.77.20.80.80 > 10.77.20.1.10634: Flags [.], ack 84, win 64, options [nop,nop,TS val 3088975262 ecr 1276569580], length 0
08:52:08.155828 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [.], ack 84, win 64, options [nop,nop,TS val 3088975262 ecr 1276569580], length 0
08:52:08.157044 eth1 In IP 10.77.20.80.80 > 10.77.20.1.10634: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 3088975263 ecr 1276569580], length 172: HTTP: HTTP/1.0 200 OK
08:52:08.157112 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 3088975263 ecr 1276569580], length 172: HTTP: HTTP/1.0 200 OK
08:52:08.157159 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1276569581 ecr 3088975263], length 0
08:52:08.157164 eth1 Out IP 10.77.20.1.10634 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1276569581 ecr 3088975263], length 0
08:52:08.157203 eth1 In IP 10.77.20.80.80 > 10.77.20.1.10634: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 3088975263 ecr 1276569581], length 16: HTTP
08:52:08.157214 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 3088975263 ecr 1276569581], length 16: HTTP
08:52:08.157235 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1276569581 ecr 3088975263], length 0
08:52:08.157246 eth1 Out IP 10.77.20.1.10634 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1276569581 ecr 3088975263], length 0
08:52:08.157292 eth1 In IP 10.77.20.80.80 > 10.77.20.1.10634: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 3088975263 ecr 1276569581], length 0
08:52:08.157302 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1276569581 ecr 3088975263], length 0
08:52:08.157305 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 3088975263 ecr 1276569581], length 0
08:52:08.157321 eth1 Out IP 10.77.20.1.10634 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1276569581 ecr 3088975263], length 0
08:52:08.157344 eth1 In IP 10.77.20.80.80 > 10.77.20.1.10634: Flags [.], ack 85, win 64, options [nop,nop,TS val 3088975264 ecr 1276569581], length 0
08:52:08.157346 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [.], ack 85, win 64, options [nop,nop,TS val 3088975264 ecr 1276569581], length 0
08:52:08.157361 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1276569582 ecr 3088975263], length 0
08:52:08.157363 eth1 Out IP 10.77.20.1.10634 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1276569582 ecr 3088975263], length 0^C52 packets captured
52 packets received by filter
0 packets dropped by kernellearner@router:~$ Steps (10)
- Type
sudo tcpdump -n -i any tcp port 80 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
tcpdump: data link type LINUX_SLL2 tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes - The second terminal finished. Return here and press Ctrl+C to stop listening.
- Output:
08:52:07.566026 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [S], seq 3694827773, win 64240, options [mss 1460,sackOK,TS val 1957483384 ecr 0,nop,wscale 10], length 0 08:52:07.566070 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [S], seq 3694827773, win 64240, options [mss 1460,sackOK,TS val 1957483384 ecr 0,nop,wscale 10], length 0 08:52:07.566094 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [S.], seq 439892248, ack 3694827774, win 65160, options [mss 1460,sackOK,TS val 3159816111 ecr 1957483384,nop,wscale 10], length 0 08:52:07.566096 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [S.], seq 439892248, ack 3694827774, win 65160, options [mss 1460,sackOK,TS val 3159816111 ecr 1957483384,nop,wscale 10], length 0 08:52:07.566105 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1957483384 ecr 3159816111], length 0 08:52:07.566107 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1957483384 ecr 3159816111], length 0 08:52:07.566159 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1957483384 ecr 3159816111], length 83: HTTP: GET /hello.txt HTTP/1.1 08:52:07.566174 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1957483384 ecr 3159816111], length 83: HTTP: GET /hello.txt HTTP/1.1 08:52:07.566180 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [.], ack 84, win 64, options [nop,nop,TS val 3159816111 ecr 1957483384], length 0 08:52:07.566181 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [.], ack 84, win 64, options [nop,nop,TS val 3159816111 ecr 1957483384], length 0 08:52:07.568907 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 3159816114 ecr 1957483384], length 172: HTTP: HTTP/1.0 200 OK 08:52:07.568945 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 3159816114 ecr 1957483384], length 172: HTTP: HTTP/1.0 200 OK 08:52:07.568993 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0 08:52:07.568998 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0 08:52:07.569037 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 3159816114 ecr 1957483387], length 16: HTTP 08:52:07.569049 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 3159816114 ecr 1957483387], length 16: HTTP 08:52:07.569063 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0 08:52:07.569064 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0 08:52:07.569100 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 3159816114 ecr 1957483387], length 0 08:52:07.569111 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 3159816114 ecr 1957483387], length 0 08:52:07.569119 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0 08:52:07.569131 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0 08:52:07.569140 eth1 In IP 10.77.20.80.80 > 10.77.20.1.50000: Flags [.], ack 85, win 64, options [nop,nop,TS val 3159816114 ecr 1957483387], length 0 08:52:07.569143 eth0 Out IP 10.77.20.80.80 > 10.77.10.11.50000: Flags [.], ack 85, win 64, options [nop,nop,TS val 3159816114 ecr 1957483387], length 0 08:52:07.569186 eth0 In IP 10.77.10.11.50000 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0 08:52:07.569198 eth1 Out IP 10.77.20.1.50000 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1957483387 ecr 3159816114], length 0 08:52:08.155315 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [S], seq 452574860, win 64240, options [mss 1460,sackOK,TS val 1276569579 ecr 0,nop,wscale 10], length 0 08:52:08.155494 eth1 Out IP 10.77.20.1.10634 > 10.77.20.80.80: Flags [S], seq 452574860, win 64240, options [mss 1460,sackOK,TS val 1276569579 ecr 0,nop,wscale 10], length 0 08:52:08.155579 eth1 In IP 10.77.20.80.80 > 10.77.20.1.10634: Flags [S.], seq 2503747844, ack 452574861, win 65160, options [mss 1460,sackOK,TS val 3088975262 ecr 1276569579,nop,wscale 10], length 0 08:52:08.155588 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [S.], seq 2503747844, ack 452574861, win 65160, options [mss 1460,sackOK,TS val 3088975262 ecr 1276569579,nop,wscale 10], length 0 08:52:08.155639 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1276569580 ecr 3088975262], length 0 08:52:08.155646 eth1 Out IP 10.77.20.1.10634 > 10.77.20.80.80: Flags [.], ack 1, win 63, options [nop,nop,TS val 1276569580 ecr 3088975262], length 0 08:52:08.155778 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1276569580 ecr 3088975262], length 83: HTTP: GET /hello.txt HTTP/1.1 08:52:08.155798 eth1 Out IP 10.77.20.1.10634 > 10.77.20.80.80: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1276569580 ecr 3088975262], length 83: HTTP: GET /hello.txt HTTP/1.1 08:52:08.155824 eth1 In IP 10.77.20.80.80 > 10.77.20.1.10634: Flags [.], ack 84, win 64, options [nop,nop,TS val 3088975262 ecr 1276569580], length 0 08:52:08.155828 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [.], ack 84, win 64, options [nop,nop,TS val 3088975262 ecr 1276569580], length 0 08:52:08.157044 eth1 In IP 10.77.20.80.80 > 10.77.20.1.10634: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 3088975263 ecr 1276569580], length 172: HTTP: HTTP/1.0 200 OK 08:52:08.157112 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 3088975263 ecr 1276569580], length 172: HTTP: HTTP/1.0 200 OK 08:52:08.157159 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1276569581 ecr 3088975263], length 0 08:52:08.157164 eth1 Out IP 10.77.20.1.10634 > 10.77.20.80.80: Flags [.], ack 173, win 63, options [nop,nop,TS val 1276569581 ecr 3088975263], length 0 08:52:08.157203 eth1 In IP 10.77.20.80.80 > 10.77.20.1.10634: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 3088975263 ecr 1276569581], length 16: HTTP 08:52:08.157214 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 3088975263 ecr 1276569581], length 16: HTTP 08:52:08.157235 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1276569581 ecr 3088975263], length 0 08:52:08.157246 eth1 Out IP 10.77.20.1.10634 > 10.77.20.80.80: Flags [.], ack 189, win 63, options [nop,nop,TS val 1276569581 ecr 3088975263], length 0 08:52:08.157292 eth1 In IP 10.77.20.80.80 > 10.77.20.1.10634: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 3088975263 ecr 1276569581], length 0 08:52:08.157302 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1276569581 ecr 3088975263], length 0 08:52:08.157305 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 3088975263 ecr 1276569581], length 0 08:52:08.157321 eth1 Out IP 10.77.20.1.10634 > 10.77.20.80.80: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 1276569581 ecr 3088975263], length 0 08:52:08.157344 eth1 In IP 10.77.20.80.80 > 10.77.20.1.10634: Flags [.], ack 85, win 64, options [nop,nop,TS val 3088975264 ecr 1276569581], length 0 08:52:08.157346 eth0 Out IP 10.77.20.80.80 > 10.77.10.10.50000: Flags [.], ack 85, win 64, options [nop,nop,TS val 3088975264 ecr 1276569581], length 0 08:52:08.157361 eth0 In IP 10.77.10.10.50000 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1276569582 ecr 3088975263], length 0 08:52:08.157363 eth1 Out IP 10.77.20.1.10634 > 10.77.20.80.80: Flags [.], ack 190, win 63, options [nop,nop,TS val 1276569582 ecr 3088975263], length 0 - Press Ctrl + C
- Output:
52 packets captured 52 packets received by filter 0 packets dropped by kernel
learner@rootvolt:~$ netlab shell phone -- curl -sS --local-port 50000 http://10.77.20.80/hello.txt[sudo] password for learner: Hello from web.learner@rootvolt:~$ netlab shell laptop -- curl -sS --local-port 50000 http://10.77.20.80/hello.txtHello from web.learner@rootvolt:~$ Steps (9)
- Type
netlab shell phone -- curl -sS --local-port 50000 http://10.77.20.80/hello.txt - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
Hello from web. - Type
netlab shell laptop -- curl -sS --local-port 50000 http://10.77.20.80/hello.txt - Press Enter
- Output:
Hello from web.
Phone keeps outside port 50000. Router changes laptop’s port to 10634 in this run; your number will differ. Laptop’s answer on site is 10.77.20.80:80 → 10.77.20.1:10634. On home it is 10.77.20.80:80 → 10.77.10.10:50000.
Stop listeners and leave shells. Run netlab mode nat off from the VM, then netlab status. This cleanup replay ends with Modes on: none. Following modules expect NAT off unless they ask for it; a reset alone keeps enabled modes on.
learner@rootvolt:~$ netlab mode nat offMode nat is off.learner@rootvolt:~$ netlab status # nat is offLab is up. Modes on: none. Fault: none.
MACHINE NETWORK ADDRESS DEFAULT ROUTE COMPARED WITH THE START
laptop home 10.77.10.10/24 10.77.10.1 same
phone home 10.77.10.11/24 10.77.10.1 same
router home, site 10.77.10.1/24 10.77.20.1/24 - same
web site 10.77.20.80/24 10.77.20.1 same
Switch sw-home (home): laptop, phone, router
Switch sw-site (site): router, web
Services: web http 80, web https 443, web http 8080, web ssh 22learner@rootvolt:~$ Steps (6)
- Type
netlab mode nat off - Press Enter
- Output:
Mode nat is off. - Type
netlab status # nat is off - Press Enter
- Output:
Lab is up. Modes on: none. Fault: none. MACHINE NETWORK ADDRESS DEFAULT ROUTE COMPARED WITH THE START laptop home 10.77.10.10/24 10.77.10.1 same phone home 10.77.10.11/24 10.77.10.1 same router home, site 10.77.10.1/24 10.77.20.1/24 - same web site 10.77.20.80/24 10.77.20.1 same Switch sw-home (home): laptop, phone, router Switch sw-site (site): router, web Services: web http 80, web https 443, web http 8080, web ssh 22
- Compare inside and outside pairs at named interfaces.
- Follow the answer through the reverse translation.
- Separate routing, translation and access rules.
Next, Practice: TCP, UDP, and Ports builds your own evidence record.