UPnP NAT Traversal

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Scumbumbo

    #1

    UPnP NAT Traversal

    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 GetPortMappingC ount() as Integer
    Dim Router as New UPnPNAT()

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

    Return Router.StaticPo rtMappingCollec tion.Count
    End Function

    However, the StaticPortMappi ngCollection (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!
  • Scumbumbo

    #2
    Re: UPnP NAT Traversal

    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!

    Comment

    Working...