NETWORKS & TRANSPORTAI-REVIEWED

How do NAT mappings and inbound filtering differ?

Useful first: IP addresses · optional, not a requirement

Choose your depth

Stay with the essentials, or look closer.

Simple explanation
2 min read · estimate

YOUR GOALSeparate the address translation a NAT performs from its decision to admit an incoming packet.

Translation and permission

An outside address for an inside conversation

Network Address Translation changes addresses as packets cross a network boundary. This article focuses on IPv4 address-and-port translation, called NAPT, carrying unicast UDP datagrams. Several internal applications can share one outside IPv4 address, with port mappings helping distinguish their traffic. Basic NAT translates addresses alone; not every kind of NAT works exactly like NAPT.

[1] [3]

A mapping is not an invitation

Imagine a game sending from an internal address and port. The NAT records which outside address and port represent that endpoint. A returning packet can then be translated back. A separate filtering decision may still reject the packet because of where it came from. Finding a mapping therefore does not prove that every outside sender can reach the game.

[2] [4]

The record can expire

Traffic-created mappings usually have a finite lifetime. If the traffic that refreshes a mapping stops, its idle timer can run out. An application that learns its outside address through STUN has learned an observation, not reserved that address forever. A later conversation may need fresh state; keep-alive behavior belongs to the application's protocol design.

[3] [5]
THE IDEA TO KEEP

Ask both where a packet would be translated and whether it is allowed in.

ONE THING TO WATCH OUT FOR

Once a NAT has a mapping, any incoming packet is allowed through.

Translation state and incoming-packet filtering answer different questions.

A QUICK CHECK, NOT A TEST
A UDP application has a NAT mapping, but a packet from a new outside sender is rejected. Is that contradictory?
Show the explanation

No: filtering can reject a packet even when translation state exists. A mapping supplies translation state. Filtering can still restrict the external senders allowed to use it; UDP itself does not prohibit NAT.

Progress is saved only in this browser.

KEEP EXPLORINGUDP
Was this explanation clear?
Report a mistake by email
Basic explanation
2 min read · estimate

YOUR GOALUse concrete address-and-port examples to distinguish mapping reuse, inbound filtering and idle expiry.

Trace two independent decisions

Does changing the destination change the mapping?

Suppose 10.0.0.7:53000 appears outside as 203.0.113.9:62000. Send from that same UDP endpoint to two different servers. Endpoint-independent mapping reuses the outside endpoint across destinations; address-dependent mapping keys reuse to the destination IP, and address-and-port-dependent mapping also considers its port. All 192.0.2, 198.51.100 and 203.0.113 addresses here are documentation examples, not live test targets.

[4] [6]

Which sender may use the mapping?

Now assume the client has sent only to 198.51.100.20:40000. With address-dependent filtering, a packet from that IP at port 40001 passes this NAT filter; with address-and-port-dependent filtering, it does not. Endpoint-independent filtering does not restrict the remote source IP or port for the active mapping. Other firewall or application checks can still reject traffic. Mapping reuse alone tells you none of these permissions.

[2] [4]

Idle timeout is not a universal stopwatch

In a hypothetical NAT with a five-minute idle timer, ordinary outbound UDP traffic at minute four refreshes the mapping; it does not have to expire five minutes after creation. RFC 4787 generally requires a minimum two-minute UDP mapping timer, with specific well-known destination-port exceptions, and recommends a default of at least five minutes. These are implementation requirements and recommendations, not measurements of your router or a universal keep-alive interval.

[2] [3]
THE IDEA TO KEEP

Keep the internal UDP endpoint fixed when comparing destinations, and examine filtering separately.

ONE THING TO WATCH OUT FOR

Endpoint-independent mapping means endpoint-independent filtering.

Reusing an outside endpoint does not determine which remote senders may send back.

A QUICK CHECK, NOT A TEST
A client has sent only to 198.51.100.20:40000. Which incoming packet passes an address-dependent NAT filter for its active mapping?
Show the explanation

A packet from 198.51.100.20:40001. Address-dependent filtering checks whether the client contacted the sender's IP, regardless of that sender's port. The other IP fails this rule; the same-port requirement belongs to address-and-port-dependent filtering.

Progress is saved only in this browser.

KEEP EXPLORINGUDP
Was this explanation clear?
Report a mistake by email
Advanced explanation
3 min read · estimate

YOUR GOALIdentify why inbound traffic may not preserve a mapping, trace hairpinning, and limit what an observed outside endpoint proves.

Refresh direction and return paths

Not every packet resets the timer

RFC 4787 requires outbound refresh for UDP mappings and permits inbound refresh; receiving traffic alone is not a portable keep-alive strategy. RFC 7857 adds important qualifications: inbound packets matching an endpoint-independent-filtering mapping but denied a new session by security policy should not refresh it, even with inbound refresh enabled. Outbound ICMP errors or TCP resets sent in response to inbound packets should not refresh mappings either. This avoids treating rejection traffic as continued interest.

[2] [3]

Hairpinning turns an external destination back inside

Suppose a second internal application's active mapping is 10.0.0.8:54000 to 203.0.113.9:62001. The first application sends to 203.0.113.9:62001; a hairpinning NAT translates and forwards that packet back to 10.0.0.8:54000. RFC 4787 requires this UDP behavior and presentation of the sender's external address and port. This is a path through the NAT using an external destination, not direct delivery to the peer's private address. Actual device support and filtering still matter.

[2] [4]

An observed endpoint is not a connectivity guarantee

A STUN Binding response reports the source address and port seen by the server. That result alone cannot prove another peer will get through the NAT's filters, or that the mapping will remain alive. STUN is a building block for traversal protocols, not a complete solution by itself. Keep protocol context too: RFC 7857 specifies protocol-dependent defaults for endpoint-independent mapping and filtering, so a successful TCP exchange does not establish UDP behavior. Check the actual peer path rather than relying on one NAT label.

[5] [3]
THE IDEA TO KEEP

Record mapping, filtering, refresh direction and hairpinning as separate properties.

ONE THING TO WATCH OUT FOR

Incoming packets always keep a NAT mapping alive.

Inbound refresh is optional, and policy-rejected traffic should not refresh the mapping even when inbound refresh is enabled.

A QUICK CHECK, NOT A TEST
A NAT refreshes an active UDP mapping only on outbound traffic. The local application stops sending, but inbound packets keep arriving. What may happen?
Show the explanation

The mapping can expire when its idle timer runs out. Under the stated outbound-only policy, incoming traffic does not refresh the timer. The mapping can expire; neither packet arrival nor an existing mapping makes it permanent.

Progress is saved only in this browser.

KEEP EXPLORINGUDP
Was this explanation clear?
Report a mistake by email
GO STRAIGHT TO THE SOURCE

Keep asking. Check the details.

Source-checked using AI (OpenAI Codex) on . The checks covered sources, examples, and quizzes for this article version.

No human review is claimed. AI review can miss errors; check the original sources below.

  1. RFC 3022 — Traditional IP Network Address Translator
  2. RFC 4787 — NAT Behavioral Requirements for Unicast UDP
  3. RFC 7857 — Updates to NAT Behavioral Requirements
  4. RFC 5128 — Peer-to-Peer Communication across NATs
  5. RFC 8489 — Session Traversal Utilities for NAT (STUN)
  6. RFC 5737 — IPv4 Address Blocks Reserved for Documentation
How explanations are prepared