20.1 Why NAT breaks SIP: private addresses in Via, Contact, and SDP
Module 2 showed what a NAT routerNAT router. The home router that translates private addresses to a public address. Where Alice and Bob each have one, they are NAT A and NAT B. does: it rewrites the IP source address and the UDP or TCP source port of each outgoing packet, and remembers the change in a NAT mappingNAT mapping. The NAT router's record of one private address and port and the public port it uses for them. It ends after a time with no outgoing traffic., so that replies can come back. It does not change the text inside the packet.
SIP writes addresses inside the text. A phone behind NAT knows only its own private address, so it writes that address in three places, and each one breaks something different:
| Where | Example from Alice’s phone | What breaks |
|---|---|---|
| Via (sent-by) | Via: SIP/2.0/UDP 192.168.1.20:5060 |
Responses: the server sends them to port 5060, not to the port the NAT router opened |
| Contact | Contact: <sip:alice@192.168.1.20:5060> |
Incoming requests: calls to Alice, and in-dialog requests such as BYE |
| SDP c= and m= | c=IN IP4 192.168.1.20 · m=audio 49170 |
The media: the other side sends RTP to a private address |
“The problem arises when a client advertises its address to receive media and it exists in a private network that is not accessible from outside the NAT.”Read the section ↗
A second problem sits in the NAT router itself: it lets packets in only through a mapping that an outgoing packet created, and only for as long as traffic keeps the mapping alive. So a fix needs two things: the right address, and an open mapping when the packet arrives.
Signaling and media are separate problems with separate fixes. A call can ring and connect, and still have no audio, or audio in one direction only. Keep both in mind for the rest of this module.
20.2 NAT behaviour: mapping and filtering
NAT routers differ in two choices. RFC 4787 names them. The older STUN names (“full cone”, “symmetric”) are still common, but they mix the two choices together:
“STUN [RFC3489] used the terms "Full Cone", "Restricted Cone", "Port Restricted Cone", and "Symmetric" to refer to different variations of NATs applicable to UDP only. Unfortunately, this terminology has been the source of much confusion, as it has proven inadequate at describing real-life NAT behavior.”Read the section ↗
Mapping: when the phone sends from the same private address and port to a new destination, does the router reuse the same public port?
“Endpoint-Independent Mapping: The NAT reuses the port mapping for subsequent packets sent from the same internal IP address and port (X:x) to any external IP address and port.”Read the section ↗
“Address and Port-Dependent Mapping: The NAT reuses the port mapping for subsequent packets sent from the same internal IP address and port (X:x) to the same external IP address and port while the mapping is still active.”Read the section ↗
Filtering: which outside senders may send packets in through a mapping?
“In other words, for receiving packets from a specific external endpoint, it is necessary for the internal endpoint to send packets first to that external endpoint's IP address and port.”Read the section ↗
| Old name | Mapping | Filtering | Who can send in through the mapping |
|---|---|---|---|
| Full cone | Endpoint-independent (EIM) | Endpoint-independent (EIF) | Anyone |
| Restricted cone | EIM | Address-dependent (ADF) | Any port of an IP address the phone has sent to |
| Port-restricted cone | EIM | Address and port-dependent (APDF) | Only the exact address and port the phone has sent to |
| Symmetricsymmetric NAT. A NAT router that makes a new mapping for each destination. The address that STUN reports works only for the STUN server. | Address and port-dependent (APDM) | APDF | Only the exact address and port, and each destination gets a new public port |
The mapping behaviour decides whether an address that a phone learns from one server is any use to another host. With endpoint-independent mapping, the public port is the same for every destination. With a symmetric NAT, the port that the STUN server saw is valid only for the STUN server. RFC 4787 therefore requires endpoint-independent mapping, but many routers, firewalls, and carrier-grade NATs (CGNAT, with addresses from 100.64.0.0/10) still do not have it:
“REQ-1: A NAT MUST have an "Endpoint-Independent Mapping" behavior.”Read the section ↗
The filtering behaviour decides who may send first. With address and port-dependent filtering, a packet gets in only if the phone has already sent to that exact address and port. Most fixes in this module work because the phone sends first, and the other side replies to the address it saw.
20.3 Signaling fixes: rport, received, Contact rewriting, Path, SIP Outbound
rport and received fix the responses (Module 10). The phone adds rport with no value; the server fills in the source port, and sends the response there, through the mapping that the request opened:
“A client, compliant to this specification (clients include UACs and proxies), MAY include an "rport" parameter in the top Via header field value of requests it generates. This parameter MUST have no value; it serves as a flag to indicate to the server that this extension is supported and requested for the transaction.”Read the section ↗
“If the "sent-protocol" component indicates an unreliable unicast transport protocol, such as UDP, and there is no "maddr" parameter, but there is both a "received" parameter and an "rport" parameter, the response MUST be sent to the IP address listed in the "received" parameter, and the port in the "rport" parameter. The response MUST be sent from the same address and port that the corresponding request was received on.”Read the section ↗
Contact rewriting fixes the incoming requests. The phone’s Contact is private, so the edge proxy or SBC stores the address that the REGISTER came from, with the binding. When a call arrives, the Request-URI stays the Contact, but the proxy sends the packet to the stored address. This is the usual hosted NAT traversal of SBCs. It works with every NAT type, because the proxy replies only to the address and port it heard from:
Call flow · the SBC sends Bob's call through his NAT mapping
The SBC reaches Bob through his NAT mapping
- SIP
- TCP / IP
Bob writes his private address in Via and Contact. The rport flag asks for the response at the source port.
All steps as text
- Bob → NAT router: REGISTER. Bob writes his private address in Via and Contact. The rport flag asks for the response at the source port.
- NAT router → SBC: REGISTER. The NAT router maps 10.0.0.30:5060 to 198.51.100.200:52010. The SIP text does not change.
- SBC → NAT router: 200 OK. The SBC adds received and rport, and sends the response to 198.51.100.200:52010. The NAT mapping is open.
- NAT router → Bob: 200 OK. The NAT router delivers it. The SBC also stores 198.51.100.200:52010 with the binding.
- Bob → SBC: keepalive every 25 s. Bob sends a keepalive, shorter than the NAT timeout. The NAT mapping stays open.
- SBC → NAT router: INVITE. A call arrives. The Request-URI is Bob's Contact, but the SBC sends the packet to 198.51.100.200:52010.
- NAT router → Bob: INVITE. The NAT router has a mapping for port 52010, and the SBC sent from 5060. Bob receives the INVITE.
- Bob → NAT router: 180 Ringing. Bob's phone rings. The response goes back the same way.
- NAT router → SBC: 180 Ringing. Contact rewriting works with every NAT type: the SBC only replies to the address and port it heard from.
It works only if the phone sends and receives SIP on the same port, so the mapping that its requests open is the one that its incoming requests use:
“Even if the SIP Outbound mechanism is not used, clients generating SIP requests SHOULD use the same IP address and port (i.e., socket) for both transmission and receipt of SIP messages.”Read the section ↗
Path (RFC 3327, Module 12) makes calls for Bob pass the edge proxy that holds his NAT mapping, when the registrar sits deeper in the network. SIP Outbound (RFC 5626, Modules 12 and 19) is the standard version of all this: the phone registers each flow with an instance ID and a reg-id, keeps it alive, and the proxy sends incoming requests back over the same flow.
| Fix | Where | What it fixes |
|---|---|---|
rport and received (RFC 3581) |
Phone adds rport, server fills it in |
Responses reach the phone through its mapping |
| Contact rewriting | Edge proxy or SBC | Incoming requests reach the phone through its mapping |
| Path (RFC 3327) | Edge proxy adds it to REGISTER | Incoming requests go through the edge proxy that holds the mapping |
| SIP Outbound (RFC 5626) | Phone, edge proxy, and registrar | All of the above, plus keepalives and failover, as a standard |
None of these fix the media. The SDP still says c=IN IP4 192.168.1.20.
20.4 Keep the binding open: keepalives and short registration intervals
Every fix in 20.3 uses the phone’s NAT mapping, and the mapping lasts only while packets go out. RFC 4787 asks for at least two minutes for UDP, but many routers close a mapping after 30 to 60 seconds:
“There is great variation in the values used by different NATs. REQ-5: A NAT UDP mapping timer MUST NOT expire in less than two minutes, unless REQ-5a applies.”Read the section ↗
“Note on selection of time values: the upper bound of 29 seconds was selected, as many NATs have UDP timeouts as low as 30 seconds.”Read the section ↗
| Way to keep the mapping open | Cost | Notes |
|---|---|---|
| Keepalives from the phone: CRLF, STUN, or OPTIONS (Module 19) | A few bytes every 25–29 s | The standard way. STUN and CRLF pongs also show that the path still works |
| Short registration interval, such as 60 s | A full REGISTER, often with a digest challenge, every minute | Works, but loads the registrar. Check its Min-Expires |
| OPTIONS from the proxy to the phone | One request per phone per interval | Used by SBCs (“NAT ping”); also detects dead phones |
| INVITE retransmissions during a long ring | — | RFC 3581 asks the phone to keep sending the INVITE every 20 s |
“INVITE transactions can take an arbitrarily long amount of time to complete. As a result, the binding may expire before a final response is received. To keep the binding fresh, the client SHOULD retransmit its INVITE every 20 seconds or so.”Read the section ↗
The interval must be shorter than the shortest NAT timeout on the path. A registration that lasts an hour with no keepalives breaks after the first minute. Module 12 has the expiry clock; the common mistakes below show it again.
20.5 Media fixes: symmetric RTP, latching, media relays, SBC anchoring
The media has the same problem as the Contact, with no proxy in the middle to fix it. Three methods work together:
- Symmetric RTP (RFC 4961, Module 16): the phone sends RTP from the same port where it receives. Then the NAT mapping that its outgoing RTP opens is the path for the incoming RTP.
- Latching: the far side ignores the address in the SDP and sends to the address and port that the media really came from.
- A media relay, usually inside an SBC: the SBC replaces the SDP address of each side with one of its own ports. Each phone sends to the SBC, and the SBC latches to each source. This is media anchoring.
“Signaling intermediaries would hence modify such information so that peer UAs are given the (public) addressing information of a media relay controlled by the intermediary.”Read the section ↗
“The media relay receives the media packets on the allocated ports and uses their respective source address:ports as a destination for all media bound in the opposite direction. In other words, it "latches" or locks on these source address:port tuples.”Read the section ↗
“When operating behind a NAT and using the 'latching' technique described in [MIDDLEBOXES], SIP User Agents MUST implement Symmetric RTP/RTCP.”Read the section ↗
Latching needs the phone to send first: until Bob’s first packet arrives, the SBC has no address for him, and drops the media for him. It also needs symmetric RTP: a phone that receives on 49170 but sends from 49172 makes the SBC latch to the wrong port (Module 16). An SBC latches once per offer and answer; a new source port in the middle of a call can be an attack.
RTCP adds one more port. Classic RTCP uses the RTP port + 1, but a NAT router does not keep the ports next to each other. a=rtcp: (RFC 3605) names the RTCP port, and a=rtcp-mux (RFC 5761) puts RTP and RTCP on one port; with mux, there is only one mapping to keep open.
Now try every combination. Put Alice and Bob behind different NAT types, and turn the fixes on and off. Each packet shows its addresses before and after each NAT router:
NAT simulator · Bob registers, Alice calls him
Which packets get through?
- SIP
- RTP
- STUN / ICE
- Rewritten by NAT
Alice's NAT router
Bob's NAT router
The call connects, but there is no audio in either direction.
- 200 OK reaches Bob
- INVITE reaches Bob
- Audio Alice → Bob
- Audio Bob → Alice
- 1
REGISTER Bob → SBC
10.0.0.30:5060NAT198.51.100.200:52010→to203.0.113.5:5060Via and Contact say 10.0.0.30:5060;rport. The SBC sees 198.51.100.200:52010.
- 2
200 OK (REGISTER) SBC → Bob
203.0.113.5:5060→to198.51.100.200:52010NAT10.0.0.30:5060rport: the response goes to the source port, through the open mapping.
- 3
INVITE Alice → SBC
192.168.1.20:5060NAT198.51.100.7:40112→to203.0.113.5:5060Alice's SDP offers her media address. The SBC sees 198.51.100.7:40112.
- 4
INVITE SBC → Bob
203.0.113.5:5060→to198.51.100.200:52010NAT10.0.0.30:5060Contact rewriting: the SBC sends to 198.51.100.200:52010, where the REGISTER came from.
- 5
200 OK Bob → SBC
10.0.0.30:5060NAT198.51.100.200:52010→to203.0.113.5:5060Bob answers, with his SDP.
- 6
200 OK SBC → Alice
203.0.113.5:5060→to198.51.100.7:40112NAT192.168.1.20:5060Alice gets the answer. The call is up.
- 7
RTP first packet Alice → Bob
192.168.1.20:49170NAT198.51.100.7:40114→to10.0.0.30:3456✕10.0.0.30 is a private address: no router on the Internet can deliver it
- 8
RTP first packet Bob → Alice
10.0.0.30:3456NAT198.51.100.200:52012→to192.168.1.20:49170✕192.168.1.20 is a private address: no router on the Internet can deliver it
- 9
RTP later packets Alice → Bob
192.168.1.20:49170NAT198.51.100.7:40114→to10.0.0.30:3456✕10.0.0.30 is a private address: no router on the Internet can deliver it
- 10
RTP later packets Bob → Alice
10.0.0.30:3456NAT198.51.100.200:52012→to192.168.1.20:49170✕192.168.1.20 is a private address: no router on the Internet can deliver it
Alice 192.168.1.20 behind 198.51.100.7 · Bob 10.0.0.30 behind 198.51.100.200 · SBC 203.0.113.5 · STUN/TURN 203.0.113.50. Each phone sends RTP from the port where it receives (symmetric RTP).
Things to try:
- Turn rport off: Bob’s phone never sees the 200 OK to its REGISTER, and Alice never sees the answer to her INVITE.
- Turn Contact rewriting off: the INVITE goes to 10.0.0.30, which no router on the Internet can deliver.
- With both on and media None, the call connects with no audio. With one side on a public address, the audio goes one way.
- STUN only works for most NAT types, but not when Bob is behind a symmetric NAT.
- Media relay and ICE work for every combination.
20.6 STUN, TURN, and ICE: candidates and connectivity checks
The SBC fixes media from the network side. The phone can also fix it from its own side, with three protocols.
STUN (RFC 8489) tells a device its public address and port. The phone sends a Binding request from its media port to a STUN server, which answers with the source address it saw:
“It provides a means for an endpoint to determine the IP address and port allocated by a NAT that corresponds to its private IP address and port. It also provides a way for an endpoint to keep a NAT binding alive.”Read the section ↗
The answer is in XOR-MAPPED-ADDRESS: the address XOR the magic cookie 0x2112A442. The XOR exists because some routers found the public address inside the packet and “fixed” it:
“However, deployment experience found that some NATs rewrite the 32-bit binary payloads containing the NAT's public IP address, such as STUN's MAPPED-ADDRESS attribute, in the well-meaning but misguided attempt to provide a generic Application Layer Gateway (ALG) function.”Read the section ↗
The phone writes its STUN address in the SDP. That works with endpoint-independent mapping. With a symmetric NAT, the address is valid only for the STUN server:
“Using terminology defined in "NAT Behavioral Requirements for Unicast UDP" [RFC4787], STUN does work with Endpoint-Independent Mapping but does not work with either Address-Dependent Mapping or Address and Port-Dependent Mapping type NATs.”Read the section ↗
TURN (RFC 8656) is the fallback that always works: a server on the Internet gives the phone a relayed address, and relays media between that address and the phone. It costs a server, bandwidth, and some delay, so it is the last resort:
“When a direct communication path cannot be found, it is necessary to use the services of an intermediate host that acts as a relay for the packets.”Read the section ↗
“A TURN service will almost always provide media traffic to a SIP entity, but it is RECOMMENDED that this method would only be used as a last resort and not as a general mechanism for NAT traversal.”Read the section ↗
ICE (RFC 8445) uses both. Each side gathers its candidatescandidate. An address where a device might receive media. Host candidates are its own addresses, server-reflexive ones come from STUN, relayed ones from TURN., offers all of them in the SDP, and tests every pair with STUN requests. The controlling side then selects the highest-priority pair that works in both directions, and the media flows on it. ICE is for the media only; the signaling still needs the fixes in 20.3:
“The purpose of ICE is to discover which pairs of addresses will work. The way that ICE does this is to systematically try all possible pairs (in a carefully sorted order) until it finds one or more that work.”Read the section ↗
“Note that ICE is not intended for NAT traversal for the signaling protocol, which is assumed to be provided via another mechanism.”Read the section ↗
| Candidate | Where it comes from | Type preference | Priority (component 1) |
|---|---|---|---|
| host | The device’s own interface | 126 | 2130706431 |
| peer-reflexive (prflx) | Learned during the checks: the address the peer saw | 110 | 1862270975 |
| server-reflexive (srflx) | STUN, or TURN: the NAT router’s public address | 100 | 1694498815 |
| relayed | TURN: an address on the TURN server | 0 | 16777215 |
“priority = (2^24)*(type preference) + (2^8)*(local preference) + (2^0)*(256 - component ID)”Read the section ↗
“The RECOMMENDED values for type preferences are 126 for host candidates, 110 for peer-reflexive candidates, 100 for server-reflexive candidates, and 0 for relayed candidates.”Read the section ↗
In the SDP, each candidate is one a=candidate line: foundation, component, transport, priority, address, port, type, and for reflexive and relayed candidates the related address. a=ice-ufrag and a=ice-pwd give the short-term credentials that authenticate the checks.
a=ice-ufrag:aL3x
a=ice-pwd:asd88fgpdd777uzjYhagZg
a=candidate:1 1 UDP 2130706431 192.168.1.20 49170 typ host
a=candidate:2 1 UDP 1694498815 198.51.100.7 40112 typ srflx raddr 192.168.1.20 rport 49170
a=candidate:3 1 UDP 16777215 203.0.113.50 50000 typ relay raddr 198.51.100.7 rport 40112
The connectivity checks are STUN Binding requests sent from the media port to each remote candidate, so they open the same NAT mappings that the media will use:
“It is important to note that STUN requests are sent to and from the exact same IP addresses and ports that will be used for data (e.g., RTP, RTCP, or other protocols).”Read the section ↗
A check that fails still helps: Alice’s check opens her own NAT for Bob’s address, so Bob’s check, a moment later, gets in. Each side then sends a triggered check back on the pair that worked. This is how ICE gets through two port-restricted NATs with no relay:
Call flow · ICE through two NAT routers
ICE opens a direct path through two NATs
- SIP
- RTP media
- DNS / STUN / ICE
Alice learns her server-reflexive address, 198.51.100.7:40112.
All steps as text
- Alice → STUN server: STUN Binding. Alice learns her server-reflexive address, 198.51.100.7:40112.
- Bob → STUN server: STUN Binding. Bob learns his: 198.51.100.200:52010.
- Alice → Bob: INVITE (offer). Alice offers her host and server-reflexive candidates.
- Bob → Alice: 200 OK (answer). Bob answers with his. The highest pair, host to host, fails: both addresses are private.
- Alice → Bob: ACK. The call is up. The connectivity checks start.
- Alice → NAT B: ICE check to 52010. NAT B drops Alice's check. But NAT A now lets packets in from 198.51.100.200:52010.
- Bob → Alice: ICE check to 40112. Bob checks Alice's server-reflexive address. NAT A lets it in, and Alice answers.
- Alice → Bob: ICE check to 52010. Alice sends a triggered check. NAT B now lets it in: Bob has sent to 198.51.100.7:40112.
- Alice → Bob: RTP direct. The pair works both ways. Media flows directly, with no relay.
Behind a symmetric NAT, the checks come from a new public port. The peer learns it as a peer-reflexive candidate:
“If this transport address is different from that of other candidates the agent already learned, it represents a new candidate (peer-reflexive candidate), which then gets tested by ICE just the same as any other candidate.”Read the section ↗
Pick the NAT types and servers, and see which candidates each side gathers, which pairs work, and which one ICE selects:
ICE candidate checker · Alice is the controlling agent
Which candidate pair does ICE select?
Alice's NAT router
Bob's NAT router
ICE failed: no pair works. Turn on the TURN server: a relay works behind any NAT.
Alice's candidates
- host
192.168.1.20:49170priority 2130706431a=candidate:1 1 UDP 2130706431 192.168.1.20 49170 typ host - server-reflexive
198.51.100.7:40112priority 1694498815a=candidate:2 1 UDP 1694498815 198.51.100.7 40112 typ srflx raddr 192.168.1.20 rport 49170
STUN returned it as XOR-MAPPED-ADDRESS 0001 bda2 e721 c045: the address XOR the magic cookie, so a router that rewrites addresses cannot find it.
Bob's candidates
- host
10.0.0.30:3456priority 2130706431a=candidate:1 1 UDP 2130706431 10.0.0.30 3456 typ host - server-reflexive
198.51.100.200:52010priority 1694498815a=candidate:2 1 UDP 1694498815 198.51.100.200 52010 typ srflx raddr 10.0.0.30 rport 3456
STUN returned it as XOR-MAPPED-ADDRESS 0001 ea38 e721 c08a: the address XOR the magic cookie, so a router that rewrites addresses cannot find it.
Alice's checklist, highest priority first
| Alice (local) | Bob (remote) | Pair priority | Result |
|---|---|---|---|
host 192.168.1.20:49170 | host 10.0.0.30:3456 | 9151314442783293438 | Fails |
host 192.168.1.20:49170 | server-reflexive 198.51.100.200:52010 | 7277816997797167103 | Fails |
The 8 checks, in order
- Alice from host to
10.0.0.30:3456: 10.0.0.30 is a private address: no router on the Internet can deliver it - Bob from host to
192.168.1.20:49170: 192.168.1.20 is a private address: no router on the Internet can deliver it - Alice from host to
198.51.100.200:52010: Filtered: nothing was sent from this mapping to 198.51.100.7:40112 yet - Bob from host to
198.51.100.7:40112: Filtered: nothing was sent from this mapping to 198.51.100.200:52014 yet - Alice from host to
10.0.0.30:3456: 10.0.0.30 is a private address: no router on the Internet can deliver it - Bob from host to
192.168.1.20:49170: 192.168.1.20 is a private address: no router on the Internet can deliver it - Alice from host to
198.51.100.200:52010: Filtered: nothing was sent from this mapping to 198.51.100.7:40112 yet - Bob from host to
198.51.100.7:40112: Filtered: nothing was sent from this mapping to 198.51.100.200:52014 yet
Many SBCs and gateways run ICE lite: they are on a public address, offer only host candidates, and only answer checks. In WebRTC, ICE is mandatory, and the candidates often arrive one by one after the offer (“trickle ICE”); Module 26 covers it.
20.7 SIP ALG: why router “helpers” often break calls
Many routers have a SIP ALGSIP ALG. A router feature that rewrites the addresses inside SIP and SDP. It is often buggy, and it breaks NAT fixes that already work.: an application layer gateway that reads SIP on port 5060 and rewrites the private addresses inside it. It sounds like a fix. In practice, it is one of the most common causes of SIP faults behind NAT, and the standards ask for it to be off:
“REQ-10: To eliminate interference with UNSAF NAT traversal mechanisms and allow integrity protection of UDP communications, NAT ALGs for UDP-based protocols SHOULD be turned off.”Read the section ↗
“ALGs have limitations (as per RFC 4787 [RFC4787] Section 7, RFC 3424 [RFC3424], and [RFC5245] Section 18.6), and experience shows they can have an adverse impact on the functionality of SIP. This includes problems such as requiring the media and signaling to traverse the same device and not working with encrypted signaling and/or payload.”Read the section ↗
| What the ALG does | What breaks |
|---|---|
| Rewrites Contact and c= to the public address, but keeps the private port | Media goes to a port with no mapping: one-way audio |
| Rewrites the SDP, so the SBC trusts it and does not latch | The fix that would have worked is now skipped |
| Changes the message length but not Content-Length | The message is malformed; the server drops it or returns 400 |
| Rewrites Via, then rewrites the response back | Breaks rport handling, or the phone rejects the response |
| Opens its own mappings, and closes them on its own timers | Calls fail after a few minutes, or incoming calls stop |
| Cannot read TLS | Has no effect, which is one reason to use TLS |
How to recognise it: capture on both sides of the router. Without an ALG, the SIP text is the same on both sides; only the IP and UDP headers differ. With an ALG, the Via, Contact, or SDP changes. A Via with the router’s public address, from a phone that has a private one, is the usual sign. Common menu names are “SIP ALG”, “SIP helper”, “SIP passthrough”, and “SIP fixup”.
20.8 One-way audio: a step-by-step diagnosis
One-way audio is the classic NAT symptom: the call connects, and one side hears nothing. Work through it in order. Each step uses a trace from the SBC or proxy, and if possible from both phones.
- Which direction is missing? “Bob hears Alice, Alice hears nothing” means the RTP towards Alice is lost or ignored. Start from the side that hears nothing.
- Does RTP leave the sender? Capture at the sender, or at the SBC for the leg towards it. No RTP at all is not NAT: check hold and direction attributes (
a=sendonly,a=inactive, Module 15), or a muted device. - Where is the sender sending? Compare the destination of the RTP with the c= and m= in the SDP it received. A private address there means the media was never fixed (20.5).
- Where does the receiver’s media really come from? Compare the source address and port of its RTP with its own SDP. A different public port is normal behind NAT; it means the far side must latch. A different port on the phone itself is asymmetric RTP.
- Does a firewall or NAT router let the RTP in? Look for the packets on the outside of the router and not on the inside. A port forward for 5060 alone, with no rule for the RTP port range, gives exactly this.
- Is there an ALG? Compare the SIP inside and outside the router (20.7).
- Does the audio arrive but stay silent? Then it is not NAT: check the payload type and codec (Module 15), and SRTP keys and the crypto suite (Module 18).
| Symptom | Likely cause | Fix |
|---|---|---|
| One-way audio, SDP shows a private address | Signaling fixed, media not | Media relay with latching, or ICE |
| One-way audio, SDP shows the public IP with the private port | SIP ALG | Turn the ALG off |
| One-way audio, only on incoming trunk calls to a PBX | RTP ports not forwarded | Open or forward the RTP range, or let the provider latch |
| No audio either way, STUN in use | Symmetric NAT | TURN, ICE, or a media relay |
| Audio for the first minute, then calls stop arriving | NAT mapping expired | Keepalives shorter than the NAT timeout |
| Audio both ways, but the call drops after 32 s | ACK lost (Module 8), often the Contact behind NAT | Contact rewriting, Record-Route on the SBC |
Common mistakes
SIP ALG left on in the router
An office has phones that use rport, and an SBC that latches. It works, until a new router arrives with its SIP ALG turned on. The ALG writes the public address into Contact and c=, but keeps the phone’s private port 49170. The SBC sees a public address in the SDP, so it trusts it and stops latching. It sends the media to port 49170 of the router, where there is no mapping. Calls connect; the office hears nothing.
Broken
Broken: the SIP ALG rewrites the INVITE
- SIP
- RTP media
- ⚠Problem
Alice's phone sends its private address. It uses rport, and the SBC handles NAT.
All steps as text
- Alice → NAT router: INVITE (offer). Alice's phone sends its private address. It uses rport, and the SBC handles NAT.
- NAT router → SBC: INVITE (offer). The SIP ALG rewrites Via, Contact, o=, and c= to 198.51.100.7. It keeps port 49170 in m=. Problem: The NAT router changed the SIP message.
- SBC → NAT router: 200 OK (answer). The SDP now shows a public address, so the SBC trusts it and does not latch.
- NAT router → Alice: 200 OK (answer). The ALG changes the Via back to the private address, so Alice's phone accepts the response.
- Alice → NAT router: ACK. Alice confirms the call.
- NAT router → SBC: ACK. The ALG rewrites the ACK too.
- Alice → NAT router: RTP from port 49170. Alice sends RTP from 49170. The NAT router maps it to 198.51.100.7:40210.
- NAT router → SBC: RTP from port 40210. The SBC receives Alice's audio from 198.51.100.7:40210, not from port 49170.
- SBC → NAT router: RTP to port 49170. The SBC sends to the SDP address, 198.51.100.7:49170. The router has no mapping for port 49170. Problem: One-way audio: Bob hears Alice, Alice hears nothing.
Remember: turn the SIP ALG off. A NAT router changes the IP and UDP headers only; if the SIP text differs on the two sides of the router, something is rewriting it. Moving SIP to TLS, or to a port other than 5060, also hides it from most ALGs.
Fixing the signaling but not the media
A provider sets its SBC to rewrite Contacts. Incoming calls now reach phones behind NAT, and the team closes the ticket. But the SBC still passes the SDP unchanged: Bob’s answer tells Alice to send to 10.0.0.30. Bob’s audio reaches Alice, Alice’s audio goes nowhere. The reverse also happens: an SBC that relays media for a phone whose Contact it never fixed has perfect audio on outgoing calls, and no incoming calls at all.
Broken
Broken: the SBC fixes the signaling, not the media
- SIP
- RTP media
- ⚠Problem
Alice calls Bob. Her phone is on a public address.
All steps as text
- Alice → SBC: INVITE (offer). Alice calls Bob. Her phone is on a public address.
- SBC → NAT router: INVITE (offer). The SBC fixes the signaling: it sends to 198.51.100.200:52010, where Bob registered from.
- NAT router → Bob: INVITE (offer). The NAT mapping is open, so Bob's phone rings.
- Bob → NAT router: 200 OK (answer). Bob answers. His SDP has his private address, 10.0.0.30:3456.
- NAT router → SBC: 200 OK (answer). The NAT router does not change the SDP.
- SBC → Alice: 200 OK (answer). The SBC passes the SDP unchanged. Alice receives c=IN IP4 10.0.0.30. Problem: A private address in the SDP for Alice.
- Alice → SBC: ACK. Alice confirms the call. Signaling works.
- SBC → NAT router: ACK. The SBC sends the ACK through the NAT mapping.
- NAT router → Bob: ACK. The call is up.
- Bob → Alice: RTP to 192.0.2.10. Bob sends RTP to Alice's public address. It crosses his NAT router and arrives.
- Alice → NAT router: RTP to 10.0.0.30. Alice sends RTP to 10.0.0.30, a private address. No router on the Internet delivers it. Problem: One-way audio: Alice hears Bob, Bob hears nothing.
Remember: NAT breaks signaling and media separately. Check both: the Contact and Via for the signaling, and c= and m= for the media. An SBC that handles NAT must anchor the media too, or the phones must use ICE.
Opening port 5060 but not the RTP port range
A PBX sits behind an office firewall. The installer forwards UDP 5060 to it, and calls from the SIP trunk arrive and connect. The PBX knows its public address and writes it in the SDP. But no rule forwards the RTP ports, so the carrier’s media stops at the firewall. The caller hears the PBX; the PBX hears nothing.
Call flow · port 5060 forwarded, RTP blocked
Broken: the firewall forwards port 5060 but not RTP
- SIP
- RTP media
- ⚠Problem
The carrier sends a call to the firewall's public address, port 5060.
All steps as text
- Carrier gateway → Firewall: INVITE (offer). The carrier sends a call to the firewall's public address, port 5060.
- Firewall → PBX: INVITE (offer). A port forward sends UDP 5060 to the PBX. The SIP text does not change.
- PBX → Firewall: 200 OK (answer). The PBX knows its public address, so its SDP says 198.51.100.40:10000.
- Firewall → Carrier gateway: 200 OK (answer). The signaling is correct in both directions.
- Carrier gateway → Firewall: ACK. The carrier confirms the call.
- Firewall → PBX: ACK. The call is up.
- PBX → Carrier gateway: RTP from port 10000. The PBX sends RTP out. The firewall lets it through, from a new public port.
- Carrier gateway → Firewall: RTP to port 10000. The carrier sends to the SDP address, 198.51.100.40:10000. No rule forwards UDP 10000. Problem: One-way audio: the caller hears the PBX, the PBX hears nothing.
Remember: forward the PBX’s RTP port range too (for example 10000–20000 UDP), and make it match the range set in the PBX. Or let the provider latch, if it supports symmetric RTP. Never forward a range to a phone or PBX without a firewall rule that limits the sources.
A registration interval of 3600 s behind a NAT that times out after 30–60 s
A phone registers for an hour and sends no keepalives. The NAT router closes the mapping after 30 seconds of silence. For half a minute after each REGISTER, calls arrive; then the SBC sends each INVITE to a public port that no longer leads anywhere. The phone shows “Registered”, outgoing calls work, and incoming calls fail. Try a keepalive of 25 s:
Expiry clock
Broken: a 1-hour registration behind a 30-second NAT timeout
- REGISTER and binding
- Keepalive
- NAT mapping
- Call fails
3600 sbinding granted
2REGISTERs per hour
0keepalives per hour
2%of the hour, a call reaches Bob
Select a point on the timeline, or use the arrow keys, to choose when Alice calls.
Alice calls at 10:00 (t = 600 s)
Dropped at NAT
Proxy B sends the INVITE to port 40112, but the NAT router closed that mapping and drops the packet. After Timer B (32 s), Proxy B answers Alice with 408 Request Timeout.
First failure at 0:30: the NAT mapping closed.
RFC 4787 §4.3 · Mapping Refresh
“There is great variation in the values used by different NATs. REQ-5: A NAT UDP mapping timer MUST NOT expire in less than two minutes, unless REQ-5a applies.”
Read the section ↗Remember: keepalives every 25–29 seconds (RFC 5626), shorter than the shortest NAT timeout on the path. Or let the SBC send OPTIONS to the phone. A short registration interval also works, at a cost to the registrar.
STUN alone behind a symmetric NAT
A softphone uses STUN and writes its server-reflexive address in the SDP. It works at home. In an office behind a symmetric firewall, the address that STUN returns is valid only for the STUN server: the media to Bob leaves from a new port that Bob’s NAT never saw, and Bob’s media to the STUN address is filtered. There is no audio in either direction, and STUN reports no error.
Broken: STUN alone
Broken: STUN alone behind a symmetric NAT
- SIP
- RTP media
- DNS / STUN / ICE
- ⚠Problem
Alice asks the STUN server for her public address. NAT A maps port 49170 to 40112.
All steps as text
- Alice → TURN server: STUN Binding. Alice asks the STUN server for her public address. NAT A maps port 49170 to 40112.
- Bob → TURN server: STUN Binding. Bob does the same. NAT B maps port 3456 to 52010.
- Alice → Bob: INVITE (offer). Alice offers 198.51.100.7:40112 in c= and m=. The INVITE crosses both NATs and a proxy, not drawn.
- Bob → Alice: 200 OK (answer). Bob answers with 198.51.100.200:52010, his STUN address.
- Alice → Bob: ACK. The call is up.
- Alice → NAT B: RTP to port 52010. NAT A is symmetric: it makes a new mapping, 40116, for Bob. NAT B drops the packet, because Bob never sent to 40116.
- Bob → NAT A: RTP to port 40112. Bob sends to 40112. NAT A drops it: that mapping is for the STUN server only. Problem: No audio in either direction.
Remember: STUN works only with endpoint-independent mapping. Behind a symmetric NAT you need a relay: TURN with ICE, or a media relay in an SBC. ICE uses TURN only when no direct pair works, so it costs little to configure it.
Summary
- A phone behind NAT writes its private address in Via, Contact, and SDP. Each breaks something different: responses, incoming requests, and media.
- A NAT router has a mapping behaviour and a filtering behaviour (RFC 4787). “Symmetric” NAT makes a new mapping for each destination, so an address learned from one server is useless to everyone else.
- rport fixes responses; Contact rewriting, Path, and SIP Outbound fix incoming requests. All need the phone to use one socket, and the mapping to stay open.
- Keepalives every 25–29 s keep the mapping open; a long registration interval alone does not.
- For the media: symmetric RTP from the phone, latching and a media relay in the SBC.
- STUN finds the public address, TURN relays when nothing else works, and ICE tests every candidate pair and selects the best one that works.
- A SIP ALG rewrites SIP badly and disables the fixes that work: turn it off.
- Diagnose one-way audio in order: which direction, does RTP leave, where does it go, where does it come from, does the firewall let it in, is there an ALG.