WireGuard: Difference between revisions

Added documentation how to use wg-quick with configFile
Explicitly enable wireguard. The module contains a backward compatibility 'mode' that checks if any interfaces are defined and then enables the module itself, but that's generally not how nixos modules should work. So explicitly add it to the example to show how it should be done.
Line 20: Line 20:
===Server setup===
===Server setup===
Enable WireGuard on the server via <tt>/etc/nixos/configuration.nix</tt>:
Enable WireGuard on the server via <tt>/etc/nixos/configuration.nix</tt>:
<syntaxHighlight lang="nix">
<syntaxhighlight lang="nix">
{
{
   ...
   ...
Line 32: Line 32:
   };
   };


  networking.wireguard.enable = true;
   networking.wireguard.interfaces = {
   networking.wireguard.interfaces = {
     # "wg0" is the network interface name. You can name the interface arbitrarily.
     # "wg0" is the network interface name. You can name the interface arbitrarily.
Line 76: Line 77:
   ...
   ...
}
}
</syntaxHighlight>
</syntaxhighlight>


===Client setup===
===Client setup===
<syntaxHighlight lang="nix">
<syntaxhighlight lang="nix">
{
{
   ...
   ...
Line 86: Line 87:
   };
   };
   # Enable WireGuard
   # Enable WireGuard
  networking.wireguard.enable = true;
   networking.wireguard.interfaces = {
   networking.wireguard.interfaces = {
     # "wg0" is the network interface name. You can name the interface arbitrarily.
     # "wg0" is the network interface name. You can name the interface arbitrarily.
Line 123: Line 125:
   ...
   ...
}
}
</syntaxHighlight>
</syntaxhighlight>


Multiple connections can be configured by configuring multiple interfaces under {{nixos:option|networking.wireguard.interfaces}}.
Multiple connections can be configured by configuring multiple interfaces under {{nixos:option|networking.wireguard.interfaces}}.