Programmatically determine the type of router NAT

I need to programmatically determine the type of router NAT in my program. I looked through some of the STUN related answers and UPnP related SO information. But they did not receive final answers.

I looked at STUN RFC (rfc 5389) and did not indicate how to determine the type of NAT. He mentions that the previous version (RFC 3489) did provide a mechanism for determining the type of NAT. But it is also mentioned that

Further. the classic STUN algorithm for classifying NAT types was erroneous, as many NATs did not fit into the types defined there.

Considering the above, could you please advise how I should go further with determining the type of NAT router in my software. Also, now that RFC 3489 is out of date, are there any other means?

Thanks in advance.

+4
source share
1 answer

RFC 3489 has been split into three different RFCs:

RFC 5389 is the basic STUN protocol. The basic protocol for the STUN binding request and binding response is basically the same as RFC 3489. The protocol header is updated with a magic cookie that takes up some transaction identifier field. Some STUN attributes are overridden. Several new ones were added (in particular, XOR_MAPPED_ADDRESS). Some changes to how STUN auth is executed. NAT behavior and discussion of classification has moved to RFC 5780.

RFC 5780 - "Study of Nat Behavior Using STUN." The main change in NAT type discovery was to distinguish between NAT port mapping behavior separately from NAT filtering behavior. While RFC 3489 will try to classify NAT into one of several encoders ("cone", "restricted port", "symmetric"), which was too general to describe NAT.

RFC 5769 - Just describe how the hexadecimal dump of several types of STUN messages will look like.

Out of curiosity, I think it’s useful to know if your application works for NAT. But how will knowing NAT behavior affect your code path?

Shameless plugin - use my STUN server code hosted on GitHub.

+5
source

Source: https://habr.com/ru/post/1387543/


All Articles