ntop / n2n

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

build on macbook m1 #867

Open privking opened 2 years ago

privking commented 2 years ago

how to build on macbook m1?

Logan007 commented 2 years ago

I think this duplicates #773. So far, no answer has been found.

zhaogang92 commented 2 years ago

I successfully ran it on the m1 pro chip. I tried installing tuntap with homebrew, but it failed and there is nothing showing on the system preference panel.

So instead I installed Tunnelblick 3.8.7beta02. I didn't change the config. After installing it, you'll find the TunnelBlink icon in the systray at the top right corner. Right-click it and you'll see a menu item about installing kernel extension. Install it (this requires you to restart your macOS into recovery mode and reduce the security policy). Then back to n2n, compile it using the normal Linux commands then it should work (one minor thing, it's better to make sure that the server node and client node use the same version, otherwise it may fail).

Hope it helps:)

Oliver0624 commented 2 years ago

@zhaogang92 Did you really succeed ?

I installed Tunnelblick 3.8.7beta02 and the kernel extension. Here's the output when I ran edge:

./edge -c Terra-Master-120 -I id-599 -l supernode:7654 -vvvv -f
28/Oct/2021 17:41:26 [edge_utils.c:3774] adding supernode = supernode:7654
28/Oct/2021 17:41:26 [edge.c:1085] starting n2n edge 3.1.0 Oct 28 2021 17:34:32
28/Oct/2021 17:41:26 [edge.c:1091] using compression: none.
28/Oct/2021 17:41:26 [edge.c:1092] using null cipher.
28/Oct/2021 17:41:26 [edge.c:1100] ERROR: unable to become root [1/Operation not permitted]
28/Oct/2021 17:41:26 [edge_utils.c:392] number of supernodes in the list: 1
28/Oct/2021 17:41:26 [edge_utils.c:394] supernode 0 => supernode:7654
28/Oct/2021 17:41:26 [edge_utils.c:467] WARNING: encryption is disabled in edge
28/Oct/2021 17:41:26 [edge_utils.c:483] successfully created resolver thread
28/Oct/2021 17:41:26 [edge.c:1122] automatically assign IP address by supernode
28/Oct/2021 17:41:26 [edge.c:1134] skip PING to supernode
28/Oct/2021 17:41:26 [edge_utils.c:1262] send REGISTER_SUPER to [supernode:7654]
28/Oct/2021 17:41:26 [edge_utils.c:1040] sent=79 to
28/Oct/2021 17:41:26 [edge.c:1194] send REGISTER_SUPER to supernode [supernode:7654] asking for IP address
28/Oct/2021 17:41:26 [edge_utils.c:2419] Rx N2N_UDP of size 50 from [supernode:7654]
28/Oct/2021 17:41:26 [edge_utils.c:2671] Rx REGISTER_SUPER_ACK from 00:00:00:00:00:00 [supernode:7654] (external 183.17.224.168:26219) with 3 attempts left
28/Oct/2021 17:41:26 [edge.c:1205] received REGISTER_SUPER_ACK from supernode for IP address asignment
28/Oct/2021 17:41:26 [tuntap_osx.c:54] ERROR: Unable to open any tap devices /dev/tap0 through /dev/tap254. Is this user properly authorized to access those descriptors?
28/Oct/2021 17:41:26 [tuntap_osx.c:55] ERROR: Please read https://github.com/ntop/n2n/blob/dev/doc/Building.md

It looks like it failed because it cannot open tap device. By the way, My macOS version is 12.0.1 Monterey.

zhaogang92 commented 2 years ago

@Oliver0624 Yeah I use it to connect to my home desktop since yesterday.

From your output, I can think of two things:

  1. Use sudo to run edge. I also ran edge without sudo yesterday and failed to connect (I'm not quite sure if the newer version of edge drops the requirement on sudo).
  2. The version I used is 2.8.0, because my linux desktop installed a pretty old version, so I have to use an old version on my Mac too (BTW, initially I also built the newest 3.1.0 version and failed to connect).
zhaogang92 commented 2 years ago

@Oliver0624 Oh I forgot to add, did you enter MacOS recovery mode to reduce the security policy?

Oliver0624 commented 2 years ago

@zhaogang92 Thank you !

I've found the problem. ALL two options under "reduce the security policy" should be enabled. After do that and reinstall kernel extension, it works.

And my n2n version is 3.1.

zhaogang92 commented 2 years ago

@Oliver0624 That's interesting. Actually, I only enabled one.. Probably it's caused by the difference between 3.1 and 2.8.

Oliver0624 commented 2 years ago

@zhaogang92 I tried again with only the first option checked, and it still works. But once I reboot my Mac, I must re-install the kernel extension, or edge cannot open the tap device properly. My macOS version is 12.0.1 Monterey, and this problem must be caused by Tunnelblick, not n2n.

zhaogang92 commented 2 years ago

@Oliver0624 I haven't rebooted yet. But it seems very annoying. Hope Tunnelblick can get updated soon.

BTW, I'm wondering if it's good to update the doc a little bit to include info for M1 chip? There are already a few issues posted on it.

hamishcoleman commented 2 years ago

@zhaogang92 I've been reading along with interest - I'm not a Mac user, but it almost sounds like the process for M1 matches what I have heard might be the planned process for the x86_64 systems as well (which is even more reason to get it documented better)

Are you able to summarise your process? If you post a summary, I can make a Pull Request out of it (Or you could make the Pull Request yourself)

zhaogang92 commented 2 years ago

@hamishcoleman Sorry forgot to respond.. Yeah, I'll write a summary in this thread probably tomorrow (then you can make a PR). Hope it could help other mac m1 users :)

And now I can confirm the problem mentioned by @Oliver0624 above, after a few days using the new mac. Now every time after reboot, we need to re-install the TunnelBlick extension (but somehow I feel this is either an intentional design or limited by MacOS itself). It's not a big problem though as we don't need to reboot very often.

huye commented 2 years ago

I don't know if I can't do it, or is it different from what you said? After running "csrutil disable", there is still no tap device after restarting. And when there is a tap device, I can't Ping it. I don't know where the problem is?

XiangkunFang commented 1 year ago

Hi, I was running n2n latest version and following the steps posted above, but when running edge on my mac, it stuck at ''[edge_utils.c:1568] WARNING: supernode not responding, now trying [xx.xx.xx.xx:5000], and the supernode just keeps showing '10/Jan/2023 15:29:31 [sn_utils.c:1222] assign IP 10.216.167.167/24 to tap adapter of edge 10/Jan/2023 15:29:31 [sn_utils.c:1137] authentication failed' Can anyone help with this situation? Many thanks!