即使在使用 Mirror 框架进行端口映射 UPnP (Mono.Nat) 后仍然无法通过 Internet 连接

Still cannot connect through Internet even after PortMapping UPnP (Mono.Nat) with the Mirror framework

即使在 PortMapping(使用 Mono.Nat)通过 Mirror from one Network to other networks through the internet doesn't work. Project File Download

连接到主机的 public IP 地址之后

UPnP 已启用:

我认为问题不在脚本内部,因为该端口已在路由器设置中打开。端口映射脚本:

private void DeviceFound(object sender, DeviceEventArgs args)
{
    Debug.Log("1");
    INatDevice device = args.Device;
    Debug.Log("2");
    Mapping map = new Mapping(Protocol.Tcp, 7777, 7777);
    Mapping map2 = new Mapping(Protocol.Udp, 7777, 7777);
    Debug.Log("3");
    device.CreatePortMap(map);
    device.CreatePortMap(map2);
    Debug.Log("4");
    int test = device.GetAllMappings().Length;
    Debug.Log(test);
    foreach (Mapping portMap in device.GetAllMappings())
    {
        Debug.Log("5");
        Debug.Log(portMap.ToString());
    }
}
private void DeviceLost(object sender, DeviceEventArgs args)
{
    INatDevice device = args.Device;
    Mapping map = new Mapping(Protocol.Tcp, 7777, 7777);
    Mapping map2 = new Mapping(Protocol.Udp, 7777, 7777);
    device.DeletePortMap(map);
    device.DeletePortMap(map2);

}

编辑:

两个路由器都启用了 UPnP,缺少的是防火墙设置。我不得不禁用两个防火墙 在路由器设置上使用主机的 public IP 地址通过互联网连接。 ps。非常感谢@nIcEcOw。