Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
ISO/IEC 29341-26-11 defines the WANIPConnection v2 service, a core UPnP component within the Internet Gateway Device (IGD) architecture. This service standardizes the management of IP-based WAN connections, enabling applications and devices on a local network to interact with the external internet through a residential or enterprise gateway. The v2 specification extends the original v1 with critical enhancements for IPv6 dual-stack operation, improved error reporting, and richer connection status metadata.
The service model revolves around a single conceptual WAN IP connection that can be in one of several well-defined states: Disconnected, Connecting, Connected, and PendingDisconnect. Each state transition is governed by specific actions such as GetStatusInfo, GetConnectionTypeInfo, and the connection request cycle. The service exposes state variables that reflect real-time link parameters including external IP address, port mapping lease durations, and NAT mode.
The WANIPConnection v2 service defines a rich set of actions that can be categorized into connection management, NAT traversal, and status inquiry groups. The connection management group includes RequestConnection and ForceTermination, which give applications programmatic control over the WAN link state. The NAT traversal group — the most practically relevant — provides AddPortMapping, DeletePortMapping, GetSpecificPortMappingEntry, and GetListOfPortMappings.
Each port mapping entry is uniquely identified by a combination of RemoteHost, ExternalPort, and Protocol (TCP or UDP). The v2 specification introduces the LeaseDuration argument, enabling ephemeral mappings for peer-to-peer and real-time communication applications. This is a significant improvement over v1, where port mappings persisted indefinitely once created. The service also exposes the PossiblePortMappingNumberOfEntries variable, allowing clients to query the gateway’s port mapping capacity before attempting bulk operations.
A major v2 enhancement is the explicit modeling of NAT modes. The NATEnabled state variable indicates whether NAT is active on the WAN connection. When disabled, the gateway operates in pure routing mode with public IP addresses assigned to LAN-side devices — a configuration increasingly common in IPv6 deployments. The v2 service also reports the ExternalIPAddress and the new ExternalIPv6Address variable, supporting dual-stack gateway architectures.
| Action | Description | Key Arguments (Out) |
|---|---|---|
| GetStatusInfo | Retrieve current connection status and uptime | NewConnectionStatus, NewLastConnectionError, NewUptime |
| AddPortMapping | Create a port forwarding rule on the gateway | NewRemoteHost, NewExternalPort, NewProtocol, NewInternalPort, NewLeaseDuration |
| DeletePortMapping | Remove a specific port mapping | NewRemoteHost, NewExternalPort, NewProtocol |
| GetSpecificPortMappingEntry | Retrieve details of a specific mapping | NewInternalPort, NewInternalClient, NewLeaseDuration |
| GetListOfPortMappings | Enumerate all port mappings (paginated) | NewPortMappingList, NewTotalMappings |
| ForceTermination | Disconnect the WAN IP connection | None |
| RequestConnection | Initiate the WAN connection setup | None |
When implementing a WANIPConnection v2 control point (the UPnP client), several engineering patterns emerge. First, always query GetStatusInfo before attempting port mapping operations — a gateway in Disconnected state will reject mapping requests with appropriate error codes. Second, implement pagination handling for GetListOfPortMappings, as gateways may enforce a maximum page size (typically 100 entries) even when many more mappings exist.
Error code handling in v2 is more granular. The LastConnectionError variable provides enumerated error codes covering DNS resolution failures, PPP negotiation errors, IP address conflicts, and authentication problems. Control points should map these to user-facing diagnostics rather than displaying raw error codes. Additionally, the service exposes UpTime in seconds, which can be used to calculate connection stability metrics over time.