Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| docs:techref:unetd [2022/08/29 18:59] – document additions from last unetd bump in master nbd | docs:techref:unetd [2023/12/22 01:17] (current) – [Example setup] systemcrash | ||
|---|---|---|---|
| Line 22: | Line 22: | ||
| * configurable domain suffix | * configurable domain suffix | ||
| * allows creating freeform service definitions, | * allows creating freeform service definitions, | ||
| + | * Supports peer discovery via BitTorrent ' | ||
| ===== Building ===== | ===== Building ===== | ||
| Line 39: | Line 40: | ||
| ===== Example setup ===== | ===== Example setup ===== | ||
| - | This set of example commands assumes two OpenWrt routers with the IP addresses '' | + | === Preparation === |
| - | This creates a new JSON file test.json and also generates a signing key as test.json.key (if it doesn' | + | This set of example commands assumes two OpenWRT routers with the IP addresses '' |
| + | |||
| + | Note: '' | ||
| + | |||
| + | === Example === | ||
| + | |||
| + | |||
| + | This creates a new JSON file '' | ||
| # unet-cli test.json create | # unet-cli test.json create | ||
| - | This creates a VXLAN tunnel definition and adds all hosts that are members of the '' | + | |
| + | Result: | ||
| + | < | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | This creates a VXLAN tunnel definition | ||
| # unet-cli test.json add-service l2-tunnel type=vxlan members=@ap | # unet-cli test.json add-service l2-tunnel type=vxlan members=@ap | ||
| - | This connects to 192.168.1.13 over SSH, generates an unetd interface named '' | + | |
| + | Result: | ||
| + | < | ||
| + | { | ||
| + | ... | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | ], | ||
| + | " | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | This connects to 192.168.1.13 over SSH, and on 192.168.1.13, generates an unetd interface named '' | ||
| # unet-cli test.json add-ssh-host ap1 root@192.168.1.13 endpoint=192.168.1.13 tunnels=vx0: | # unet-cli test.json add-ssh-host ap1 root@192.168.1.13 endpoint=192.168.1.13 tunnels=vx0: | ||
| + | |||
| + | Note: you will authenticate via SSH, either user:pass or key based, if that was set up in advance. | ||
| + | |||
| + | Result: | ||
| + | < | ||
| + | { | ||
| + | ... | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | ] | ||
| + | } | ||
| + | }, | ||
| + | ... | ||
| + | }</ | ||
| + | |||
| This does the same for the other host: | This does the same for the other host: | ||
| # unet-cli test.json add-ssh-host ap2 root@192.168.1.15 endpoint=192.168.1.15 tunnels=vx0: | # unet-cli test.json add-ssh-host ap2 root@192.168.1.15 endpoint=192.168.1.15 tunnels=vx0: | ||
| + | |||
| + | Result: | ||
| + | < | ||
| + | { | ||
| + | ... | ||
| + | " | ||
| + | ... | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | ] | ||
| + | } | ||
| + | }, | ||
| + | ... | ||
| + | }</ | ||
| + | |||
| This signs the network data and uploads it to unetd running on 192.168.1.13: | This signs the network data and uploads it to unetd running on 192.168.1.13: | ||
| # unet-cli test.json sign upload=192.168.1.13 | # unet-cli test.json sign upload=192.168.1.13 | ||
| | | ||
| - | Please note that in this case, uploading the data to one of the two hosts is enough, because once it has processed the update, it will find the endpoint address of the other host and sync the network data with it automatically. After that last command, the unetd network should be up on both sides and the VXLAN tunnel created as well. | + | By now, uploading the data to one of the two hosts is enough, because once it (192.168.1.13) |
| ===== Configuration ===== | ===== Configuration ===== | ||
| Line 67: | Line 147: | ||
| | '' | | '' | ||
| | '' | | '' | ||
| + | | '' | ||
| The '' | The '' | ||
| Line 81: | Line 162: | ||
| " | " | ||
| " | " | ||
| - | " | + | " |
| + | " | ||
| + | " | ||
| + | " | ||
| + | ] | ||
| }, | }, | ||
| " | " | ||
| Line 115: | Line 200: | ||
| == Config properties: == | == Config properties: == | ||
| - | ^ Name ^ Type ^ Description ^ | + | ^ Name ^ Type ^ Description |
| - | | port | int | Wireguard tunnel port (can be overriden for individual hosts) | | + | | '' |
| - | | keepalive | int | Interval (in seconds) for keepalive and forcing peer reconnection attempts | | + | | '' |
| - | | peer-exchange-port | int | Port for exchanging peer messages on the WireGuard tunnel (0: disabled) | | + | | '' |
| + | | '' | ||
| == Host properties: == | == Host properties: == | ||
| - | ^ Name ^ Type ^ Description ^ | + | ^ Name ^ Type ^ Description |
| - | | key | string | Wireguard public key | | + | | '' |
| - | | groups | array of strings | Names of groups that the host is a member of | | + | | '' |
| - | | ipaddr | array of strings | Local IP addresses of the host (IPv4 or IPv6) | | + | | '' |
| - | | subnet | array of strings | Subnets routed by the host (IPv4 or IPv6) (format: ''< | + | | '' |
| - | | port | int | Wireguard tunnel port (overrides '' | + | | '' |
| - | | peer-exchange-port | int | Host specific port for exchanging peer messages on the WireGuard tunnel (0: disabled) | | + | | '' |
| - | | endpoint | string | Public endpoint address (format: ''< | + | | '' |
| - | | gateway | string | Name of another host to use as gateway (can be used for avoiding direct connections with all other peers from this host) | | + | | '' |
| == Service properties == | == Service properties == | ||
| - | ^ Name ^ Type ^ Description ^ | + | ^ Name |
| - | | type | string | Service type | | + | | '' |
| - | | config | object | Service type specific config options | | + | | '' |
| - | | members | array of strings | Members assigned to this service (use '' | + | | '' |
| ==== CLI usage ==== | ==== CLI usage ==== | ||
| Line 164: | Line 250: | ||
| pex_port=< | pex_port=< | ||
| keepalive=< | keepalive=< | ||
| + | stun=[+|-]< | ||
| - host options (add-host, add-ssh-host, | - host options (add-host, add-ssh-host, | ||
| key=< | key=< | ||
| Line 192: | Line 279: | ||
| </ | </ | ||
| + | |||
| + | ==== DHT support ==== | ||
| + | |||
| + | For DHT peer discovery, the unet-dht package needs to be installed, and dht enabled in the interface on the nodes. For NAT support, you also need to configure at least one working STUN server in the network data. While peers can find each other through DHT directly, STUN is needed for figuring out the external wireguard port and establishing a network connection over it. | ||
| + | Please note that DHT based discovery needs some time for peers to actually discover each other, sometimes 1-3 minutes. | ||
| + | |||