WireGuard: Difference between revisions

Completed article
m Adding peers to the server configuration: Corrected configuration file, added italics
Line 150: Line 150:


* Open the server configuration file - <code>nano wg0.conf</code>
* Open the server configuration file - <code>nano wg0.conf</code>
* Add the <code>[Peer]</code> section as follows:
* Add the <code>[Peer]</code> section, marked in italics, as follows:
[Interface]
[Interface]
  ## Local Address : A private IP address for wg0 interface.
  ## Local Address : A private IP address for wg0 interface.
  Address = 10.20.10.1/24
  Address = 10.20.10.1/24
Line 164: Line 164:
  PostDown = iptables -D FORWARD -i wg0 -j ACCEPT
  PostDown = iptables -D FORWARD -i wg0 -j ACCEPT
  PostDown = iptables -t nat -D POSTROUTING -o em1 -j MASQUERADE<br>
  PostDown = iptables -t nat -D POSTROUTING -o em1 -j MASQUERADE<br>
  [Peer]
  ''[Peer]''
  [Peer]
  ''# one client which will be setup to use 10.20.10.2 IP''
# one client which will be setup to use 10.20.10.2 IP
  ''PublicKey = 92p5r33HRrEvzlQJIdANcyIKx0JgtNV5VfQOOwLnFwM=''
  PublicKey = 92p5r33HRrEvzlQJIdANcyIKx0JgtNV5VfQOOwLnFwM=
  ''AllowedIPs = 10.20.10.2/32''
  AllowedIPs = 10.20.10.2/32
* Tweak the file to match your client configuration:
* Tweak the file to match your client configuration:
** <code>PublicKey = 92p5r33HRrEvzlQJIdANcyIKx0JgtNV5VfQOOwLnFwM=</code> - the public key generated for the client.
** <code>PublicKey = 92p5r33HRrEvzlQJIdANcyIKx0JgtNV5VfQOOwLnFwM=</code> - the public key generated for the client.