7

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
9

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 used for a period of time (usually between 5 and 60 minutes).

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. Of course, normal TCP connections are properly closed, which means the NAT router can forget about it.

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 | |
  • 1
    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
  • 2
    @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
  • 2
    @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
  • 2
    To offer some support for @Tonny: we had professional routers a few years back with only 16 MB RAM and they used to fill up very quickly with DNS scans and such. – Zac67 Mar 16 '18 at 18:26
  • 2
    @Zac67 Exactly, and to get support you have to get a paid-for support contract. Or the router was ISP provided and support was part of the mandatory services fee included in the ISP contract. I have been forced to be network admin for both categories. Some admins will never encounter this in the wild (I wish I was that lucky), but there are parts of the world where this sort of thing is quite common. I'm still convinced it is on-topic. – Tonny Mar 17 '18 at 11:24

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.