xref: /netbsd-src/usr.sbin/wgconfig/wgconfig.8 (revision 5aa6767554eef703e48b3539626e685f7650707b)
1.\"	$NetBSD: wgconfig.8,v 1.11 2024/01/15 08:29:14 wiz Exp $
2.\"
3.\" Copyright (C) Ryota Ozaki <ozaki.ryota@gmail.com>
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.Dd August 20, 2020
31.Dt WGCONFIG 8
32.Os
33.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
34.Sh NAME
35.Nm wgconfig
36.Nd configure wg interface parameters
37.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
38.Sh SYNOPSIS
39.Nm
40.Li wg Ns Ar N\|
41.Op Cm "show all"
42.\"
43.Nm
44.Li wg Ns Ar N\|
45.Cm "show peer" Ar name
46.Op Fl Fl show-preshared-key
47.\"
48.Nm
49.Li wg Ns Ar N\|
50.Cm "show private-key"
51.\"
52.Nm
53.Li wg Ns Ar N\|
54.Cm "set private-key" Ar "filename"
55.\"
56.Nm
57.Li wg Ns Ar N\|
58.Cm "set listen-port" Ar port
59.\"
60.Nm
61.Li wg Ns Ar N\|
62.Cm "add peer" Ar name Ar pubkey
63.Op Fl Fl preshared-key Ns Li \&= Ns Ar filename
64.Oo Fl Fl endpoint Ns Li \&= Ns Ar ip Ns Li \&: Ns Ar port Oc
65.Oo
66.Fl Fl allowed-ips Ns Li \&= Ns Ar ip1 Ns Li \&/ Ns Ar cidr1 Ns
67.Op Li \&, Ns Ar ip2 Ns Li \&/ Ns Ar cidr2 Ns Li \&, Ns Ar ...
68.Oc
69.\"
70.Nm
71.Li wg Ns Ar N\|
72.Cm "delete peer" Ar name
73.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
74.Sh DESCRIPTION
75The
76.Nm
77utility is used to configure or display a
78.Xr wg 4
79interface's parameters and status.
80Every
81.Xr wg 4
82interface can be configured with an IP address using
83.Xr ifconfig 8 ,
84a private key generated with
85.Xr wg-keygen 8 ,
86an optional listen port,
87and a collection of peers.
88Each peer has a public key and allowed IP addresses, and may optionally
89have a fixed endpoint IP address and a preshared secret key.
90.Pp
91The following commands are supported:
92.Bl -tag -width abcd
93.It Cm "show all"
94Show all peers.
95No secret keys are included in the output.
96.It Cm "show peer" Ar name Op Fl Fl show-preshared-key
97Show the peer named
98.Ar name .
99By default, no secret keys are included in the output.
100With
101.Fl Fl show-preshared-key ,
102also display the secret preshared key that the peer was configured to
103have with the
104.Fl Fl preshared-key
105option to
106.Nm
107.Li wg Ns Ar N Cm "add peer" .
108.It Cm "show private-key"
109Show the private key that was set with
110.Nm
111.Li wg Ns Ar N Cm "set private-key" .
112.It Cm "set private-key" Ar filename
113Set the private key of
114.Li wg Ns Ar N\|
115to the base64-encoded private key in the file at
116.Ar filename .
117.It Cm "set listen-port" Ar port
118Set the UDP port number that
119.Li wg Ns Ar N\|
120listens for incoming sessions on.
121This allows a peer to start a new session without having a specific
122endpoint IP address configured.
123.It Cm "add peer" Ar name Ar pubkey Op Ar options ...
124Add a peer.
125The argument
126.Ar name
127may be passed to
128.Nm
129.Li wg Ns Ar N Cm "show peer"
130and
131.Nm
132.Li wg Ns Ar N Cm "delete peer" .
133The argument
134.Ar pubkey
135is the peer's base64-encoded public key, as printed by
136.Nm wg-keygen
137.Fl Fl pub .
138.Pp
139The following options may be specified:
140.Bl -tag -width abcd
141.It Fl Fl preshared-key Ns Li \&= Ns Ar filename
142Set a secret preshared key generated by
143.Nm wg-keygen
144.Fl Fl psk .
145.Pp
146If the preshared key can be arranged in advance on a medium not subject
147to eavesdropping, then it defends against possible future quantum
148cryptanalysis of the X25519 key agreement.
149.Nm
150still uses X25519 key agreements in order to erase past
151session keys so that past session transcripts remain secret should one
152of the endpoints be compromised in the future; the preshared key is an
153additional measure on top.
154.It Fl Fl endpoint Ns Li \&= Ns Ar ip Ns Li \&: Ns Ar port
155Set the peer's endpoint address outside the tunnel.
156This is optional for a VPN server if the
157.Nm
158interface is configured to listen on a port number.
159.It Fl Fl allowed-ips Ns Li \&= Ns Ar ip1 Ns Li \&/ Ns Ar cidr1 Ns \
160    Op Li \&, Ns Ar ip2 Ns Li \&/ Ns Ar cidr2 Ns Li \&, Ns Ar ...
161Set the IP address ranges that the peer is allowed to select inside the
162tunnel.
163.El
164.It Cm "delete peer" Ar name
165Delete the peer
166.Ar name
167previously added with
168.Nm
169.Li wg Ns Ar N Cm "add peer" Ar name .
170.El
171.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
172.Sh EXAMPLES
173See
174.Xr wg 4
175for an example network topology and
176.Nm
177usage.
178.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
179.Sh SEE ALSO
180.Xr wg 4 ,
181.Xr wg-keygen 8
182.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
183.Sh HISTORY
184The
185.Nm
186command first appeared in
187.Nx 10.0 .
188.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
189.Sh AUTHORS
190The
191.Nm
192command was written by
193.An Ryota Ozaki
194.Aq ozaki.ryota@gmail.com .
195