User Tools

Site Tools


wireguard

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
wireguard [2021/02/23 07:33] – created baumiwireguard [2021/05/09 10:31] (current) – [Assign Link Network to Wireguard-Tunnel] baumi
Line 11: Line 11:
  
 ===== Create Key Pairs ===== ===== Create Key Pairs =====
-Host A+**Host A**
 <code> <code>
-# wg genkey > privateA +root@hosta # wg genkey > privateA 
-# wg pubkey < privateA > publicA+root@hosta # wg pubkey < privateA > publicA
 </code> </code>
  
-Host B+**Host B**
 <code> <code>
-# wg genkey > privateB +root@hostb # wg genkey > privateB 
-# wg pubkey < privateB > publicB+root@hostb # wg pubkey < privateB > publicB
 </code> </code>
  
 +===== Assign Link Network to Wireguard-Tunnel =====
 +  Link-Network: 172.24.0.0/30
 +  HostA: 172.24.0.1/30
 +  HostB: 172.24.0.2/30
  
 +===== Create Config =====
 +**Host A**
 +<code>
 +root@hosta # cat /etc/wireguard/wg0.conf
 +# HostA - HostB
 +[Interface]
 +Address = 172.24.0.1/30
 +PrivateKey = <contents of privateA>
 +ListenPort = 51820
 +
 +[Peer]
 +PublicKey = <contents of publicB>
 +AllowedIPs = 172.24.0.2/32
 +</code>
 +
 +**Host B**
 +<code>
 +root@hostb # cat /etc/wireguard/wg0.conf
 +# HostB - HostA
 +[Interface]
 +Address = 172.24.0.2/30
 +PrivateKey = <contents of privateB>
 +ListenPort = 51820
 +
 +[Peer]
 +PublicKey = <contents of publicA>
 +AllowedIPs = 172.24.0.1/32
 +# Uncomment if HostB is behind NAT Router
 +# PersistentKeepAlive = 25
 +</code>
 +
 +===== Start Wireguard Tunnel =====
 +Issue on both hosts
 +<code>
 +root@hosta # wg-quick up wg0
 +root@hostb # wg-quick up wg0
 +</code>
 +===== Check Status =====
 +**Host A**
 +<code>
 +root@hosta # wg
 +interface: wg0
 +  public key: PUBLIC-KEY-A
 +  private key: (hidden)
 +  listening port: 51820
 +
 +peer: PUBLIC-KEY-B
 +  endpoint: 185.69.244.140:25920
 +  allowed ips: 172.24.0.2/32
 +  latest handshake: 1 minute, 44 seconds ago
 +  transfer: 2.80 MiB received, 1.09 MiB sent
 +</code>
 +
 +**Host B**
 +<code>
 +root@hostb # wg
 +interface: wg0
 +  public key: PUBLIC-KEY-B
 +  private key: (hidden)
 +  listening port: 51820
 +
 +peer: PUBLIC-KEY-A
 +  endpoint: 144.76.72.57:51820
 +  allowed ips: 172.24.0.1/32
 +  latest handshake: 21 seconds ago
 +  transfer: 1006.68 KiB received, 2.57 MiB sent
 +  persistent keepalive: every 25 seconds
 +</code>
 +{{tag>kb linux}}
wireguard.1614062029.txt.gz · Last modified: 2021/02/23 07:33 by baumi

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki