Skip to content

Netbird can't recover from macOS sleep #2454

Open
@trbutler

Description

@trbutler

Even if I turn on Network Monitor, Netbird is rarely functional when I wake my Mac up from sleep.

To Reproduce

Put Mac to sleep for a short while, wake it up, try to access a Netbird peer. The computer will know the IP of the peer and netbird status will say it is connected, but any access to the other peer will fail. This happens on every macOS client I try it with, whether Network Monitor is enabled or not.

Expected behavior

One would expect the connection to recover shortly after waking from sleep.

Are you using NetBird Cloud?

Using the self-hosted version updated to the latest version.

NetBird version

0.28.7

Temporary Fix

Create a MacOS launchAgent for waking from sleep that will load a shell script that pings a known, always available Netbird peer and run the equivalent of netbird down && netbird up if ping fails:

#!/bin/bash

# Define the server to ping
SERVER="[path to known netbird peer]"

# Ping the server
ping -c 1 $SERVER > /dev/null 2>&1

# Check the exit status of the ping command
if [ $? -ne 0 ]; then
    # Run the command if the server is unreachable
    echo "Server is unreachable; reloading Netbird.\n";
    netbird down
    netbird up
fi

What I've done is install the netbird client on the server hosting the Netbird docker container so I have a reliable point to connect to, then check to see if I can in fact connect to a "peer" (and not just the server processes). Obviously, this is a hack and not a permanent solution; it'd be better if this were some sort of built-in check rather than a shell script.

It might be nice if such a check could be done every so often by the netbird client even between times sleeping: I've found that if my network connection is unstable, I'll keep losing access to netbird peers midsession as well. I'm thinking about having this test script run every so many minutes rather than just on wake for now.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions