client-installation.rst 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. ================================
  2. Advanced Client Installation
  3. ================================
  4. This document tells you how to install the netclient on machines that will be a part of your Netmaker network, as well as non-compatible systems.
  5. These steps should be run after the Netmaker server has been created and a network has been designated within Netmaker.
  6. Introduction to Netclient
  7. ===============================
  8. At its heart, the netclient is a simple CLI for managing access to various WireGuard-based networks. It manages WireGuard on the host system, so that you don't have to. Why is this necessary?
  9. If you are setting up a WireGuard-based virtual network, you must configure each machine with very specific settings, so that every machine can reach it, and it can reach every machine. Any changes to the settings of any one of these machines can break those connections. Any machine that is added, removed, or modified on the network requires reconfiguring every peer in the network. This can be very time consuming.
  10. The netmaker server holds configuration details about every machine in your network and how other machines should connect to it.
  11. The netclient agent connects to the server, pushing and pulling information when the network (or its local configuration) changes.
  12. The netclient agent then configures WireGuard (and other network properties) locally, so that the network stays intact.
  13. Notes on Windows
  14. ==================================
  15. If running the netclient on windows, you must download the netclient.exe binary and run it from Powershell as an Administrator.
  16. Windows will by default have firewall rules that prevent inbound connections. If you wish to allow inbound connections from particular peers, use the following command:
  17. ``netsh advfirewall firewall add rule name="Allow from <peer private addr>" dir=in action=allow protocol=ANY remoteip=<peer private addr>``
  18. If you want to allow all peers access, but do not want to configure firewall rules for all peers, you can configure access for one peer, and set it as a Relay Server.
  19. Notes on OpenWRT
  20. ===========================
  21. Deploying on OpenWRT depends a lot on the version of OpenWRT and the hardware being used. If the primary installer does not work, there are two things you can try:
  22. 1. This community-run package for OpenWRT: https://github.com/sbilly/netmaker-openwrt
  23. 2. Manual installation:
  24. - download (wget) the netclient package for your hardware from the netclient releases: https://github.com/gravitl/netmaker/releases
  25. - rename to "netclient"
  26. - Run as root from a bash shell on OpenWRT
  27. 3. You may experience an issue with the length of the token, which has limits on some OpenWRT shells. If you run into this problem, you can use the following script to convert your token into a "netclient join" command:
  28. - `wget https://raw.githubusercontent.com/gravitl/netmaker/master/scripts/token-convert.sh`
  29. - ./token-convert <token value>
  30. - Run the output on your OpenWRT machine
  31. Modes and System Compatibility
  32. ==================================
  33. **Note: If you would like to connect non-Linux/Unix machines to your network such as phones and Windows desktops, please see the documentation on External Clients**
  34. The netclient can be run in a few "modes". System compatibility depends on which modes you intend to use. These modes can be mixed and matched across a network, meaning all machines do not have to run with the same "mode."
  35. CLI
  36. ------------
  37. In its simplest form, the netclient can be treated as just a simple, manual, CLI tool, which a user can call to configure the machine. The cli can be compiled from source code to run on most systems, and has already been compiled for x86 and ARM devices.
  38. As a CLI, the netclient should function on any Linux or Unix based system that has the wireguard utility (callable with **wg**) installed.
  39. Daemon
  40. ----------
  41. The netclient is intended to be run as a system daemon. This allows it to automatically retrieve and send updates. To do this, the netclient can install itself as a systemd service, or launchd/windows service for Mac or Windows.
  42. If running the netclient on non-systemd linux, it is recommended to manually configure the netclient as a daemon using whatever method is acceptable on the chosen operating system.
  43. Private DNS Management
  44. -----------------------
  45. To manage private DNS, the netclient relies on systemd-resolved (resolvectl). Absent this, it cannot set private DNS for the machine.
  46. A user may choose to manually set a private DNS nameserver of <netmaker server>:53. However, beware, as netmaker sets split dns, and the system must be configured properly. Otherwise, this nameserver may break your local DNS.
  47. Prerequisites
  48. =============
  49. To obtain the netclient, go to the GitHub releases: https://github.com/gravitl/netmaker/releases
  50. **For netclient cli:** Linux/Unix with WireGuard installed (wg command available)
  51. **For netclient daemon:** Systemd Linux + WireGuard
  52. **For Private DNS management:** Resolvectl (systemd-resolved)
  53. Configuration
  54. ===============
  55. The CLI has information about all commands and variables. This section shows the "help" output for these commands as well as some additional reference.
  56. CLI Reference
  57. --------------------
  58. ``sudo netclient --help``
  59. .. literalinclude:: ./examplecode/netclient-help.txt
  60. :language: YAML
  61. ``sudo netclient join --help``
  62. .. literalinclude:: ./examplecode/netclient-join.txt
  63. :language: YAML
  64. Config File Reference
  65. ------------------------
  66. There is a config file for each node under /etc/netconfig-<network name>. You can change these values and then set "postchanges" to "true", or go to the CLI and run ``netclient push -n <network>``
  67. .. literalinclude:: ./examplecode/netconfig-example.yml
  68. :language: YAML
  69. Installation
  70. ======================
  71. To install netmaker, you need a server token for a particular network, unless you're joining a network that allows manual signup, in which case you can join without a token, but the server will quarantine the machine until the admin approves it.
  72. An admin creates a token in the ACCESS KEYS section of the UI. Upon creating a token, it generates 3 values:
  73. **Access Key:** The secret key to authenticate as a node in the network
  74. **Access Token:** The secret key plus information about how to access the server (addresses, ports), all decoded by the netclient to register with the server
  75. **Install Command:** A short script that will obtain the netclient binary, register with the server, and join the network, all in one
  76. For first time installations, you can run the Install Command. For additional networks, simply run ``netclient join -t <access token>``. The raw access key will not be needed unless there are special circumstances, mostly troubleshooting incorrect information in the token (you can instead manually specify the server location).
  77. Managing Netclient
  78. =====================
  79. Viewing Logs
  80. ---------------
  81. **to view current networks**
  82. ``netclient list``
  83. **to tail logs**
  84. ``journalctl -u netclient@<net name> -f``
  85. **to view all logs**
  86. ``journalctl -u netclient@<net name>``
  87. **to get most recent log run**
  88. ``systemctl status netclient@<net name>``
  89. Making Updates
  90. ----------------
  91. ``vim /etc/netclient/netconfig-<network>``
  92. Change any of the variables in this file, and changes will be pushed to the server and processed locally on the next checkin.
  93. For instance, change the private address, endpoint, or name. See above example config file for details
  94. Adding/Removing Networks
  95. ---------------------------
  96. ``netclient join -t <token>``
  97. Set any of the above flags (netclient join --help) to override settings for joining the network.
  98. If a key is provided (-k), then a token is unnecessary, but grpc, server, ports, and network must all be provided via flags.
  99. Uninstalling
  100. ---------------
  101. ``netclient uninstall``