My ISP is Orange, with a LiveBox v4 router by Sagem.
When using DiscoverDeviceAsync, it returns the router with its IPv6 address.
Trying to open port with the IPv6 fails likely because the router doesn't accept local IPv6, but only IPv4 ones.
Moreover, it's not possible to manually specify the local IPv4 in the request because the requesting IP should match the one in the entry added, so if it's done over the IPv6 network, then they won't be the same.
To fix that, I had to do in DiscoverDeviceAsync():
-
changed:
var devices = await DiscoverAsync(portMapper, true, cancellationTokenSource);
to:
var devices = await DiscoverAsync(portMapper, false, cancellationTokenSource); //TOO: Need them all, so can keep the IPv4 one if it's there
-
changed:
var device = devices.FirstOrDefault();
to:
NatDevice device = null;
foreach (var MyDevice in devices)
{
System.Net.IPAddress Ip = MyDevice.GetIPAddress();
if (Ip.AddressFamily != System.Net.Sockets.AddressFamily.InterNetworkV6)
{
device = MyDevice;
break;
}
}
if (device == null)
{
device = devices.FirstOrDefault();
}
-
Added support for GetIPAddress() to the device classes.
Side note: with Unity, the mappings aren't automatically removed, at least in the Editor.