UPnP NAT Traversal

  • Thread starter Thread starter Scumbumbo
  • Start date Start date
S

Scumbumbo

I'm writing a VB app in Visual Studio 2005 where I'd like to automatically
setup inbound port mappings for the user on their home router. I've been
playing with trying to use the NATUPnP 1.0 Type Library (hnetcfg.dll) and
have had no luck. From what I've read the library is friendly enough that
it should be as simple as adding the reference to the NATUPnP 1.0 Type
Library and doing some pretty mindless code (for example):

Private Function GetPortMappingCount() as Integer
Dim Router as New UPnPNAT()

' Obviously in real life, I'd do some error checking here :)

Return Router.StaticPortMappingCollection.Count
End Function

However, the StaticPortMappingCollection (as well as the NATEventManager)
ends up as Nothing and so throws an exception.

Anyone who is even vaguely familiar with this stuff? I've seen sample code
in C# that I've compiled with similar results. I know I have a UPnP
capable router. A packet sniff shows that the router isn't being queried
at all, so I'm obviously doing something wrong here and hopefully it's just
a simple oversight!
 
I'm obviously doing something wrong here and
hopefully it's just a simple oversight!

Doh! My Windows based firewall was blocking UDP port 1900 traffic from my
router. Now that the traffic is allowed, the NAT traversal is working
fine. And it really _is_ easy!
 
Back
Top