Labs / Internetwork / NAT: port forwards, static, pools & traversal

Lab 3 of 3 · NAT: port forwards, static, pools & traversal

NAT traversal: two devices behind NAT, talking directly

Punch a UDP hole between two NATed peers, and see where it fails.

Open this lab Pro 5 steps

The idea

alice and bob, each behind a home router doing NAT, ask a rendezvous server where the other is, then talk directly if both send at once: NAT traversal by UDP hole punching. carol, behind a carrier-grade NAT that picks a new port for every destination, cannot join them.

What the rendezvous server sees
What the rendezvous server sees
Each side opens the door for the other
Each side opens the door for the other

Steps

  1. What do I look like from outside?

    alice is 10.0.1.10 behind aliceRouter (10.0.4.2). A rendezvous server answers with the address and port it saw. A device behind NAT cannot see its own public address, so asking someone outside is the only way to learn what to tell a peer.

    alice:~# socat - UDP4:10.0.4.10:3478,sourceport=5000,reuseaddr
  2. Knowing the address is not enough

    Both have checked in, so bob knows alice is at 10.0.4.2:5000. Try the obvious thing first, sending straight there, because seeing why it fails is what makes the trick in the next step make sense.

    bob:~# nping --udp -g 6000 -p 5000 10.0.4.2
    aliceRouter:~# conntrack -L -p udp

Pro

3 more steps in the app

  1. Punching the hole: both send at once
  2. A new port for every destination
  3. Keeping holes open, and relays
Get Pro

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Open this lab