So say you are a user behind a NAT/router on an internal network. You begin sending UDP data to an internet-facing server. The packet hits your router, it inserts an entry to allow returning packets from that server on a specific port to be forwarded to your local machine when received.

However UDP is connectionless. How does the router know when to remove this rule when the client no longer wishes to send or receive data with this server?

  • You need to give us more information. What is the router model and configuration? – Ron Maupin Mar 16 '18 at 12:40

A NAT router doesn't know when to remove a UDP mapping - it guesses.

The router simply ages (or times) out the entry when it hasn't been using for a period of time (a few minutes usually).

With TCP, there's also a similar aging/timeout to make sure that forgotten or lost sessions don't pile up but it's much longer.

UDP or TCP aging is a trade-off between router resources (fast aging) and compatibility with slow low-bandwidth sessions (slow aging). Sometimes the default settings require tweaking for your workload.

| improve this answer | |
  • And many cheap routers have too little RAM and/or sloppy firmware, leading to the RAM filling up with state-information for connections that are not longer needed, but don't get cleaned up. This leads to the fairly common ritual of having to reboot the router every couple of days/weeks. – Tonny Mar 16 '18 at 12:19
  • @Tonny, remember that such devices are off-topic here. – Ron Maupin Mar 16 '18 at 12:52
  • @RonMaupin Off topic? How come? Even though the phenomenon is quite common in consumer equipment, I've also seen enough low-end "business grade" equipment guilty of it. E.g. Cisco and Siemens DSL modem/routers used to be notorious for this sort of thing. – Tonny Mar 16 '18 at 13:46
  • @Tonny, enterprises will not stand for needing to reboot a router every few days. If you have something like a Cisco or Juniper router that requires that, then it gets fixed. We have many, many (thousands) Cisco routers, and some have been up for years. If one needs to be rebooted, even once, for something like that, it gets replaced. – Ron Maupin Mar 16 '18 at 13:52
  • @RonMaupin Serious enterprise equipment of course not. But there is this entire world of "small enterprise/business" equipment that sits somewhere between consumer stuff and big enterprise stuff. Last time I looked at the FAQ this "in-between" category was still on-topic for this site. – Tonny Mar 16 '18 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.