Skip to content

Example to forward traffic through a netbird peer #133

@werlitong

Description

@werlitong

Scenario

Imagine that you have a two Peers (A and B). Peer A advertise 8.8.8.8/32 to Peer B through Netbird's network.

If we have hosts in Peer B's subnet that may want to talk to 8.8.8.8/32 through Peer A but they simple cant/dont want to install Netbird Client. We can forward traffic to Peer B instead.

I have managed to get this working by following these steps:

In peer B:

  1. run echo 1 > /proc/sys/net/ipv4/ip_forward or adding net.ipv4.ip_forward=1 to /etc/sysctl.conf.
  2. run iptables -t nat -A POSTROUTING -o netbird_interface -j MASQUERADE

Take note that netbird_interface is the interface from wireguard. Run route -n just to be sure.
image

In hosts that are in the same local subnet of Peer B:

  1. run route add 8.8.8.8 mask 255.255.255.255 ip_of_peer_B

In my case, it was easier to push that route (static route) in my router (UDM PRO from ubiquiti). By doing this all local clients (that dont have netbird) in my home network can now access 8.8.8.8 through Peer B -> Peer A (Netbird route).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions