ntop / n2n

Peer-to-peer VPN
GNU General Public License v3.0
6.21k stars 936 forks source link

Wrong windows-edge IP address provided by mgmt port and ping failed. #626

Closed randomize00 closed 3 years ago

randomize00 commented 3 years ago

Hello, everyone. I'm tring to punch hole between my PC(windows) and NAS(Linux). I found out that I always fail to ping (from) my PC(windows), but those linux edges can ping each other.

to find out what had happened, I wrote a little program to read the output from mgmt port of the supernode,

#./a.out 127.0.0.1 5645
    id    tun_tap             MAC                edge                 hint              last_seen
-----------------------------
community: lc-1

    1     10.193.59.55/24     4A:D4:0B:46:C8:AD  183.17.227.26:43766   TNAS-E493          14

    2     10.193.59.74/24     FA:BD:0B:15:66:3E  172.31.3.118:50446    tgmserver          12

    3     10.193.59.48/0     00:FF:23:A3:33:FC  183.17.227.26:61888                      14

----------------------------------------------------------------------------------------------------
uptime 9870 | edges 3 | re

and here is the configuration on my PC:

未知适配器 本地连接( Unkown Adapter Local Connection ):

   连接特定的 DNS 后缀 . . . . . . . :
   描述(Description). . . . . . . . . . . . . . . : TAP-Windows Adapter V9
   物理地址(Pysical Address). . . . . . . . . . . . . : 00-FF-23-A3-33-FC
   DHCP 已启用(DHCP Enabled ?) . . . . . . . . . . . : 否(No)
   自动配置已启用(Auto Configuration Enabled ?). . . . . . . . . . : 是(Yes)
   本地链接 IPv6 地址. . . . . . . . : fe80::1545:2607:d665:d128%5(首选)
   IPv4 地址(IPv4 address) . . . . . . . . . . . . : 10.193.59.47(首选 Primary)
   子网掩码(Subnet Mask)  . . . . . . . . . . . . : 255.255.255.0
   默认网关(Default Gateway). . . . . . . . . . . . . :
   DHCPv6 IAID . . . . . . . . . . . : 100728611
   DHCPv6 客户端(Client) DUID  . . . . . . . : 00-01-00-01-27-48-E3-F6-94-C6-91-6F-79-DE
   DNS 服务器(DNS Server)  . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                       fec0:0:0:ffff::2%1
                                       fec0:0:0:ffff::3%1
   TCPIP 上的 NetBIOS  . . . . . . . : 已启用

Sorry for I use Chinese version of windows ( I've traslated some important words into English )

So the IP address of my tap-windows adapter is 10.193.59.47/24, not 10.193.59.48/0 which is provided by management port.

and what's more, when I ping 10.193.59.47 from my NAS, it always timeout. but when I ping 10.193.59.48, it returns From 10.193.59.55 icmp_seq=1 Destination Host Unreachable and through the log, I learned my PC(windows-edge) actually received and handled the PACKET.

So I think there may be a little mistake when supernode record the last byte of address of windows-version edge. The supernode recorded wrong address thus I failed to ping my windows edge.

randomize00 commented 3 years ago

It looks like edge received assigned IP, but failed to use correct address. Here are the a part of log in edge-windows.

04/Feb/2021 17:42:15 [edge_utils.c:3081] Adding supernode = 47.104.20.99:7654
04/Feb/2021 17:42:15 [edge.c:641] WARNING: Unknown option -f: Ignored
04/Feb/2021 17:42:15 [edge.c:919] Starting n2n edge 2.9.0.r835.9104784 Feb  2 2021 15:36:24
04/Feb/2021 17:42:15 [edge.c:925] Using compression: none.
04/Feb/2021 17:42:15 [edge.c:926] Using null cipher.
04/Feb/2021 17:42:15 [edge_utils.c:227] Number of supernodes in the list: 1
04/Feb/2021 17:42:15 [edge_utils.c:229] supernode 0 => 47.104.20.99:7654
04/Feb/2021 17:42:15 [edge_utils.c:267] WARNING: Encryption is disabled in edge
04/Feb/2021 17:42:15 [edge.c:955] Automatically assign IP address by supernode.
04/Feb/2021 17:42:15 [edge.c:966] Skip PING to supernode.
04/Feb/2021 17:42:15 [edge_utils.c:874] send REGISTER_SUPER to 47.104.20.99:7654
04/Feb/2021 17:42:15 [edge_utils.c:745] sendto sent=91 to
04/Feb/2021 17:42:15 [edge.c:1024] Send REGISTER_SUPER to supernode [47.104.20.99:7654] asking for IP address.
04/Feb/2021 17:42:15 [edge_utils.c:1974] ### Rx N2N UDP (50) from 47.104.20.99:7654
04/Feb/2021 17:42:15 [edge_utils.c:2173] Rx REGISTER_SUPER_ACK myMAC=00:00:00:00:00:00 [47.104.20.99:7654] (external 183.17.227.26:54031). Attempts 3
04/Feb/2021 17:42:15 [edge.c:1035] Received REGISTER_SUPER_ACK from supernode for IP address asignment.
Open device [name={23A333FC-0369-4F77-9874-C8CEA793C5A8}][ip=10.193.59.48][ifName=本地连接][MTU=1290][mac=00:FF:23:A3:33:FC]
WARNING: Unable to set device 本地连接 IP address [netsh interface ip set address "本地连接" static 10.193.59.48 255.255.255.0 > nul]
04/Feb/2021 17:42:15 [edge.c:1060] Created local tap device IP: 10.193.59.48, Mask: 255.255.255.0, MAC: 00:FF:23:A3:33:FC
04/Feb/2021 17:42:15 [edge.c:1138] edge started.

Sorry for the Chinese word. '本地连接' means 'Local Connection'.

Logan007 commented 3 years ago

failed to use correct address

Does netsh interface ipv4 show interface show anything unusual? Maybe some remainings of older interfaces that still block that original IP address? A former edge not able to shut down correctly? Would it work directly after a reboot... – Windows :wink: ?

randomize00 commented 3 years ago

I've rebooted my PC, but It still doesn't work... 😢

C:\Users\lc11>netsh interface ipv4 show interface

Idx     Met         MTU          状态(Status)                名称(Name)
---  ----------  ----------  ------------  ---------------------------
  1          75  4294967295  connected     Loopback Pseudo-Interface 1
  **5          25        1500  connected     本地连接**
 19          25        1500  disconnected  WLAN
 17          25        1500  connected     以太网
  8          25        1500  disconnected  本地连接* 1
 11          65        1500  disconnected  蓝牙网络连接
 21          25        1500  disconnected  本地连接* 2
 16          35        1500  connected     VMware Network Adapter VMnet1
 18          35        1500  connected     VMware Network Adapter VMnet8
Logan007 commented 3 years ago

You run as administrator, right? From your log:

Open device [name={23A333FC-0369-4F77-9874-C8CEA793C5A8}][ip=10.193.59.48][ifName=本地连接][MTU=1290][mac=00:FF:23:A3:33:FC]
WARNING: Unable to set device 本地连接 IP address [netsh interface ip set address "本地连接" static 10.193.59.48 255.255.255.0 > nul]

Is anyone able to explain why Windows' netsh command as printed in the log obviously seems to fail to set the IP address?

randomize00 commented 3 years ago

You are right. I didn't run as administrator... 😭

After I re-run the scenario as administrator, the IP of my tap-windows device on my PC is correct ...

Logan007 commented 3 years ago

So, can we close this?