Configure a WireGuard server by using nmcli
You can configure the WireGuard server by creating a connection profile in NetworkManager. Use this method to let NetworkManager manage the WireGuard connection.
Before you begin
- You have generated the public and private key for both the server and client.
- You know the following information:
- The private key of the server
- The static tunnel IP addresses and subnet masks of the client
- The public key of the client
- The static tunnel IP addresses and subnet masks of the server
About this task
This procedure assumes the following settings:
- Server:
- Private key:
YFAnE0psgIdiAF7XR4abxiwVRnlMfeltxu10s/c4JXg= - Tunnel IPv4 address:
192.0.2.1/24 - Tunnel IPv6 address:
2001:db8:1::1/64
- Private key:
- Client:
- Public key:
bnwfQcC8/g2i4vvEqcRUM2e6Hi3Nskk6G9t4r26nFVM= - Tunnel IPv4 address:
192.0.2.2/24 - Tunnel IPv6 address:
2001:db8:1::2/64
- Public key:
Procedure
Results
- Display the interface configuration of the
wg0device:# wg show wg0interface: wg0 public key: UtjqCJ57DeAscYKRfp7cFGiQqdONRn69u249Fa4O6BE= private key: (hidden) listening port: 51820 peer: bnwfQcC8/g2i4vvEqcRUM2e6Hi3Nskk6G9t4r26nFVM= allowed ips: 192.0.2.2/32, 2001:db8:1::2/128To display the private key in the output, use the
WG_HIDE_KEYS=never wg show wg0command. - Display the IP configuration of the
wg0device:# ip address show wg020: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000 link/none inet 192.0.2.1/24 brd 192.0.2.255 scope global noprefixroute wg0 valid_lft forever preferred_lft forever inet6 2001:db8:1::1/64 scope global noprefixroute valid_lft forever preferred_lft forever inet6 fe80::3ef:8863:1ce2:844/64 scope link noprefixroute valid_lft forever preferred_lft forever