As the title says, what is the difference between UDP hole punching and STUN?
Or is it the same?
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.
hole punching and STUN are quite different things.
STUN will allow a system to work out what its external IP address is (if, as is common, it is located behind a NATing firewall or equivalent). It is really of use where the IP address of the Internet connection is dynamically assigned.
[UDP] hole punching allows a mapping from a real world IP address to a specific box behind a NATing firewall - This is a security thing, but much more importantly required because of the 1:many relationship NAT introduces - so the NATing router needs to know which client to send the packet too. [ For responses to regular traffic it keeps a lookup table of associations between the From IP, Dest IP and ports used (and related ports if its doing its job well) ]