Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbreak building for FreeBSD #103

Open
wants to merge 2 commits into
base: master
from

Conversation

@mateuszkwiatkowski
Copy link

mateuszkwiatkowski commented Dec 17, 2019

I naively copied darwin files to unbreak building FreeBSD binaries. The other thing is that upstream version of water library doesn't support FreeBSD. There is a fork with added FreeBSD support https://github.com/yggdrasil-network/water and work in progress pull request to upstream: songgao/water#37

After these dirty hacks I'm able to start nebula on FreeBSD hosts but no traffic is passed between them:

$ sudo ./nebula -config config.yml
INFO[0000] Firewall rule added                           firewallRule="map[caName: caSha: direction:outgoing endPort:0 groups:[] host:a
ny ip:<nil> proto:0 startPort:0]"
INFO[0000] Firewall rule added                           firewallRule="map[caName: caSha: direction:incoming endPort:0 groups:[] host:a
ny ip:<nil> proto:1 startPort:0]"
INFO[0000] Firewall rule added                           firewallRule="map[caName: caSha: direction:incoming endPort:443 groups:[laptop
 home] host: ip:<nil> proto:6 startPort:443]"
INFO[0000] Firewall started                              firewallHash=853d3005de969aa0cb1100731e983a740ab4218f89c78189edd389ff5e05ae99
INFO[0000] Main HostMap created                          network=192.168.100.2/24 preferredRanges="[192.168.0.0/24]"
INFO[0000] UDP hole punching enabled
command: ifconfig tap0 192.168.100.2/24 192.168.100.2
command: ifconfig tap0 mtu 1300
INFO[0000] Nebula interface is active                    build=dev+20191217111808 interface=tap0 network=192.168.100.2/24
INFO[0000] Handshake message sent                        handshake="map[stage:1 style:ix_psk0]" initiatorIndex=3879127975 remoteIndex=0
 udpAddr="188.116.33.203:4242" vpnIp=192.168.100.1
INFO[0000] Handshake message received                    durationNs=446865780 handshake="map[stage:2 style:ix_psk0]" initiatorIndex=387
9127975 remoteIndex=3879127975 responderIndex=834573217 udpAddr="188.116.33.203:4242" vpnIp=192.168.100.1

tap0 interface is configured correctly:

tap0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1300
        options=80000<LINKSTATE>
        ether 58:9c:fc:10:ff:96
        inet 192.168.100.2 netmask 0xffffff00 broadcast 192.168.100.2
        groups: tap
        media: Ethernet autoselect
        status: active
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
        Opened by PID 42831

kwiat@monster-1 ~/nebula/build/freebsd (support-freebsd*) $ netstat -rn4
Routing tables

Internet:
Destination        Gateway            Flags     Netif Expire
default            192.168.0.2        UGS        igb0
127.0.0.1          link#5             UH          lo0
192.168.0.0/24     link#1             U          igb0
192.168.0.11       link#1             UHS         lo0
192.168.100.0/24   link#6             U          tap0
192.168.100.2      link#6             UHS         lo0

There's no response for who-has requests:

kwiat@monster-1 ~/nebula/build/freebsd (support-freebsd*) $ sudo tcpdump -i tap0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on tap0, link-type EN10MB (Ethernet), capture size 262144 bytes
12:55:38.490465 ARP, Request who-has 192.168.100.1 tell 192.168.100.2, length 28
12:55:39.532137 ARP, Request who-has 192.168.100.1 tell 192.168.100.2, length 28
12:55:40.559399 ARP, Request who-has 192.168.100.1 tell 192.168.100.2, length 28

Dropping it here with hope that someone would be willing to pick-up and continue this effort.
I was testing on few weeks old CURRENT:

FreeBSD monster-1 13.0-CURRENT FreeBSD 13.0-CURRENT #5 1b501770dd3-c264495(master): Wed Nov 27 01:35:34 CET 2019 root@monster-1:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64

@claassistantio

This comment has been minimized.

Copy link

claassistantio commented Dec 17, 2019

CLA assistant check
All committers have signed the CLA.

@nbrownus

This comment has been minimized.

Copy link
Collaborator

nbrownus commented Dec 17, 2019

I can likely spin a VM up shortly and push this along. My initial thoughts are that this is pushing ethernet frames (tap) through to nebula and we only reason about ip (tun) frames currently. I'm not super familiar with the BSDs anymore but I'd imagine the linux files would be a better starting point.

@mateuszkwiatkowski

This comment has been minimized.

Copy link
Author

mateuszkwiatkowski commented Dec 17, 2019

@nbrownus that's great! I'm happy to help if any assistance is needed. :-)

@dch

This comment has been minimized.

Copy link

dch commented Dec 17, 2019

@mateuszkwiatkowski neat keep me posted on progress!

@mateuszkwiatkowski

This comment has been minimized.

Copy link
Author

mateuszkwiatkowski commented Jan 24, 2020

@nbrownus Did you have a chance to take a look into this?

@nbrownus

This comment has been minimized.

Copy link
Collaborator

nbrownus commented Jan 25, 2020

Sorry, I got pulled in another direction. I'll re-review this PR and merge as a stop gap.

@nbrownus

This comment has been minimized.

Copy link
Collaborator

nbrownus commented Jan 25, 2020

Mind rebasing on master?

@mateuszkwiatkowski mateuszkwiatkowski force-pushed the runhyve:support-freebsd branch from eb43467 to 3f42be1 Jan 31, 2020
@mateuszkwiatkowski

This comment has been minimized.

Copy link
Author

mateuszkwiatkowski commented Jan 31, 2020

@nbrownus rebased and force-pushed. :-)

c.Device = c.Interface.Name()

// TODO use syscalls instead of exec.Command
fmt.Println("command: ifconfig", c.Device, c.Cidr.String(), c.Cidr.IP.String())

This comment has been minimized.

Copy link
@wadey

wadey Feb 4, 2020

Member

remove this fmt.Println and the one below, or change it to use the logger that the rest of Nebula uses (search the repository for l.Debug(…) etc). Debug level would be correct here I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.