Hi,
I'm doing python studies to write test automation scripts. As a part of that I want a script which should identify the NAT type of my network..
Please help me out in this regard...
Thx.
Hi,
I'm doing python studies to write test automation scripts. As a part of that I want a script which should identify the NAT type of my network..
Please help me out in this regard...
Thx.
As is looking for the underlying logic (and as asked how you can tell), the usual, reliable approach is to probe from the client to one or more external endpoints (STUN-style) and observe two things: (1) whether the router rewrites your source IP:port differently depending on the destination (mapping consistency), and (2) whether an external host can send packets to that mapped address without the client first sending to that external host (inbound acceptance). Those two measurements let you distinguish full-cone, restricted-cone, port-restricted and symmetric NATs, or detect UDP being blocked.
Keywords and protocol bits to search/implement: STUN binding request, MAPPED-ADDRESS, CHANGED-ADDRESS, CHANGE-REQUEST, endpoint-independent vs endpoint-dependent mapping, hairpinning. A practical test plan:
A quick Python starting point is to use a STUN helper library (many expose a simple get_ip_info() call). For example:
import stun
nat_type, external_ip, external_port = stun.get_ip_info()
print(nat_type, external_ip, external_port) Run the sequence above against two endpoints and automate comparisons and change-request checks. For the formal protocol behavior, see the STUN specification and classic NAT classification in RFC 3489 and the updated STUN spec in RFC 5389.
Jump to Post— mn_kthompson 3How would you even do that? I mean outside of python how can you figure out if you're receiving natted traffic and what kind of natting is being done?
How would you even do that? I mean outside of python how can you figure out if you're receiving natted traffic and what kind of natting is being done?
How would you even do that? I mean outside of python how can you figure out if you're receiving natted traffic and what kind of natting is being done?
When I googled regarding this, I got a tool, "NAT-Tester" which identifies the NAT of my LAN... I just need the logic / keywords so that I will script the same and embed in my automation script...
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.