lontivero / Open.NAT

Lightweight and easy-to-use class library to allow port forwarding in NAT devices with UPNP and/or PMP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wrong external ip obtained?

abouAlAbass opened this issue · comments

the library sometimes give me right external ip and the other times it give me wrong external ip
, i dont understand why ?

Your IP: 192.168.225.100
Added mapping: 192.168.225.100:1700 -> 127.0.0.1:1600

+------+-------------------------------+--------------------------------+------------------------------------+-------------------------+
| PROT | PUBLIC (Reacheable) | PRIVATE (Your computer) | Descriptopn | |
+------+----------------------+--------+-----------------------+--------+------------------------------------+-------------------------+
| | IP Address | Port | IP Address | Port | | Expires |
+------+----------------------+--------+-----------------------+--------+------------------------------------+-------------------------+
| TCP | 192.168.225.100 | 43868 | 192.168.1.120 | 43868 | uTorrent (TCP) | 01/10/2018 16:55:26|
| UDP | 192.168.225.100 | 43868 | 192.168.1.120 | 43868 | uTorrent (UDP) | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 2052 | 192.168.1.127 | 2050 | Open.Nat (Permanent lifetime) | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 2550 | 192.168.1.127 | 2550 | Open.Nat (Permanent lifetime) | 01/10/2018 16:55:26|
| UDP | 192.168.225.100 | 33437 | 192.168.1.124 | 33437 | libtorrent/1.1.3.0 at 192.168.1 | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 36788 | 192.168.1.124 | 36788 | libtorrent/1.1.3.0 at 192.168.1 | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 5895 | 192.168.1.127 | 5895 | Open.Nat (Permanent lifetime) | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 22689 | 192.168.1.117 | 22689 | BitTorrent (TCP) | 01/10/2018 16:55:26|
| UDP | 192.168.225.100 | 22689 | 192.168.1.117 | 22689 | BitTorrent (UDP) | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 24466 | 192.168.1.103 | 24466 | uTorrent (TCP) | 01/10/2018 16:55:26|
| UDP | 192.168.225.100 | 24466 | 192.168.1.103 | 24466 | uTorrent (UDP) | 01/10/2018 16:55:26|
| UDP | 192.168.225.100 | 6889 | 192.168.1.145 | 6889 | libtorrent/0.16.17.0 at 192.168 | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 4433 | 192.168.1.130 | 4433 | libtorrent/0.16.17 at 192.168.1 | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 24467 | 192.168.1.112 | 24466 | uTorrent (TCP) | 01/10/2018 16:55:26|
| UDP | 192.168.225.100 | 24467 | 192.168.1.112 | 24466 | uTorrent (UDP) | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 55768 | 192.168.1.140 | 55768 | uTorrent (TCP) | 01/10/2018 16:55:26|
| UDP | 192.168.225.100 | 55768 | 192.168.1.140 | 55768 | uTorrent (UDP) | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 44525 | 192.168.1.144 | 6881 | libtorrent/0.16.17 at 192.168.1 | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 42951 | 192.168.1.144 | 4433 | libtorrent/0.16.17 at 192.168.1 | 01/10/2018 16:55:26|
| UDP | 192.168.225.100 | 47631 | 192.168.1.144 | 6881 | libtorrent/0.16.17 at 192.168.1 | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 48310 | 192.168.1.144 | 6881 | libtorrent/0.16.17 at 192.168.1 | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 42181 | 192.168.1.144 | 4433 | libtorrent/0.16.17 at 192.168.1 | 01/10/2018 16:55:26|
| UDP | 192.168.225.100 | 47303 | 192.168.1.144 | 6881 | libtorrent/0.16.17 at 192.168.1 | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 9596 | 192.168.1.56 | 9595 | Open.Nat (Permanent lifetime) | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 8000 | 192.168.1.127 | 9000 | Open.Nat (Permanent lifetime) | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 6566 | 192.168.1.114 | 6565 | Open.Nat (Permanent lifetime) | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 9595 | 192.168.1.56 | 9595 | Open.Nat (Permanent lifetime) | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 9898 | 192.168.1.56 | 9898 | Open.Nat (Permanent lifetime) | 01/10/2018 16:55:26|
| TCP | 192.168.225.100 | 49784 | 192.168.1.123 | 6881 | libtorrent/1.1.6.0 at 192.168.1 | 01/10/2018 16:55:27|
| UDP | 192.168.225.100 | 1500 | 192.168.1.123 | 1500 | libtorrent/1.1.6.0 at 192.168.1 | 01/10/2018 16:55:27|
| TCP | 192.168.225.100 | 1500 | 192.168.1.123 | 1500 | libtorrent/1.1.6.0 at 192.168.1 | 01/10/2018 16:55:27|
| TCP | 192.168.225.100 | 22690 | 192.168.1.120 | 22689 | BitTorrent (TCP) | 01/10/2018 16:55:27|
| UDP | 192.168.225.100 | 22690 | 192.168.1.120 | 22689 | BitTorrent (UDP) | 01/10/2018 16:55:27|
| TCP | 192.168.225.100 | 1702 | 192.168.1.121 | 1603 | Open.Nat (temporary) | 01/10/2018 16:55:27|
| TCP | 192.168.225.100 | 1701 | 192.168.1.106 | 1601 | Open.Nat (Permanent lifetime) | 01/10/2018 17:05:27|
| TCP | 192.168.225.100 | 9000 | 192.168.1.106 | 10000 | Open.Nat (Permanent lifetime) | 01/10/2018 17:05:27|
+------+----------------------+--------+-----------------------+--------+------------------------------------+-------------------------+
[Removing TCP mapping] 192.168.225.100:1700 -> 127.0.0.1:1600
[Done]

Socket listening on port 1602. Remember, it is mapped to external port 1702!!!

I don't understand the table. There are no external addresses, only internal ip addresses.

I noticed that sometimes it manages to recover the correct IP external address, and when I debug the API I noticed that the problem is in the line
var device = await nat.DiscoverDeviceAsync (PortMapper.Upnp, cts);
when it retrieves the ip external address it sends a soap request to an adrese local ip 192.168.1.130 normally it must send and the request soap to the address 192.168.1.1 in this case it manages to retrieve the IP address external

when we use the api for the first timee we get correct external ip address ex : "105.104.36.154" but after expiring and relunch the sampleApp we get a new ip adress:"192.168.225.100", so we can not reach the port already opened , please reply

@abouAlAbass I will take a look at this issue during the weekend. You can help simple setting a breakpoint in the line following line and see why it is using the private ip address instead of the public one.

await CreatePortMapAsync(renewMapping);