···23## Quickstart {#module-services-netbird-quickstart}
45-The absolute minimal configuration for the netbird daemon looks like this:
67```nix
8{
···13This will set up a netbird service listening on the port `51820` associated to the
14`wt0` interface.
1516-It is strictly equivalent to setting:
1718```nix
19{
20- services.netbird.tunnels.wt0.stateDir = "netbird";
0000021}
22```
2324-The `enable` option is mainly kept for backward compatibility, as defining netbird
25-tunnels through the `tunnels` option is more expressive.
002627## Multiple connections setup {#module-services-netbird-multiple-connections}
2829-Using the `services.netbird.tunnels` option, it is also possible to define more than
30one netbird service running at the same time.
3132-The following configuration will start a netbird daemon using the interface `wt1` and
33-the port 51830. Its configuration file will then be located at `/var/lib/netbird-wt1/config.json`.
3435```nix
36{
37- services.netbird.tunnels = {
38- wt1 = {
39- port = 51830;
40- };
41- };
42}
43```
4445-To interact with it, you will need to specify the correct daemon address:
4647-```bash
48-netbird --daemon-addr unix:///var/run/netbird-wt1/sock ...
49-```
50-51-The address will by default be `unix:///var/run/netbird-<name>`.
5253-It is also possible to overwrite default options passed to the service, for
54-example:
05556```nix
57{
58- services.netbird.tunnels.wt1.environment = {
59- NB_DAEMON_ADDR = "unix:///var/run/toto.sock";
000000060 };
61}
62```
6364-This will set the socket to interact with the netbird service to `/var/run/toto.sock`.
00000000000000000
···23## Quickstart {#module-services-netbird-quickstart}
45+The absolute minimal configuration for the Netbird client daemon looks like this:
67```nix
8{
···13This will set up a netbird service listening on the port `51820` associated to the
14`wt0` interface.
1516+Which is equivalent to:
1718```nix
19{
20+ services.netbird.clients.default = {
21+ port = 51820;
22+ interface = "wt0";
23+ name = "netbird";
24+ hardened = false;
25+ };
26}
27```
2829+This will set up a `netbird.service` listening on the port `51820` associated to the
30+`wt0` interface. There will also be `netbird-wt0` binary installed in addition to `netbird`.
31+32+see [clients](#opt-services.netbird.clients) option documentation for more details.
3334## Multiple connections setup {#module-services-netbird-multiple-connections}
3536+Using the `services.netbird.clients` option, it is possible to define more than
37one netbird service running at the same time.
3839+You must at least define a `port` for the service to listen on, the rest is optional:
04041```nix
42{
43+ services.netbird.clients.wt1.port = 51830;
44+ services.netbird.clients.wt2.port = 51831;
00045}
46```
4748+see [clients](#opt-services.netbird.clients) option documentation for more details.
4950+## Exposing services internally on the Netbird network {#module-services-netbird-firewall}
00005152+You can easily expose services exclusively to Netbird network by combining
53+[`networking.firewall.interfaces`](#opt-networking.firewall.interfaces) rules
54+with [`interface`](#opt-services.netbird.clients._name_.interface) names:
5556```nix
57{
58+ services.netbird.clients.priv.port = 51819;
59+ services.netbird.clients.work.port = 51818;
60+ networking.firewall.interfaces = {
61+ "${config.services.netbird.clients.priv.interface}" = {
62+ allowedUDPPorts = [ 1234 ];
63+ };
64+ "${config.services.netbird.clients.work.interface}" = {
65+ allowedTCPPorts = [ 8080 ];
66+ };
67 };
68}
69```
7071+### Additional customizations {#module-services-netbird-customization}
72+73+Each Netbird client service by default:
74+75+- runs in a [hardened](#opt-services.netbird.clients._name_.hardened) mode,
76+- starts with the system,
77+- [opens up a firewall](#opt-services.netbird.clients._name_.openFirewall) for direct (without TURN servers)
78+ peer-to-peer communication,
79+- can be additionally configured with environment variables,
80+- automatically determines whether `netbird-ui-<name>` should be available,
81+82+[autoStart](#opt-services.netbird.clients._name_.autoStart) allows you to start the client (an actual systemd service)
83+on demand, for example to connect to work-related or otherwise conflicting network only when required.
84+See the option description for more information.
85+86+[environment](#opt-services.netbird.clients._name_.environment) allows you to pass additional configurations
87+through environment variables, but special care needs to be taken for overriding config location and
88+daemon address due [hardened](#opt-services.netbird.clients._name_.hardened) option.