Inst wireguard » History » Version 9
Michael Gunsch, 09/25/2023 04:19 PM
| 1 | 2 | Michael Gunsch | h1. Installation WireGuard unter Debian |
|---|---|---|---|
| 2 | 3 | Michael Gunsch | |
| 3 | h2. Anleitung |
||
| 4 | |||
| 5 | https://www.wireguard.com/ |
||
| 6 | |||
| 7 | 4 | Michael Gunsch | h2. Pakete installieren |
| 8 | |||
| 9 | <pre> |
||
| 10 | sudo apt install wireguard wireguard-tools |
||
| 11 | </pre> |
||
| 12 | |||
| 13 | 3 | Michael Gunsch | h2. Konfiguration |
| 14 | 4 | Michael Gunsch | |
| 15 | h3. Schlüsselpaar erzeugen |
||
| 16 | |||
| 17 | <pre> |
||
| 18 | wg genkey | tee wg_priv_key | wg pubkey > wg_pub_key |
||
| 19 | chmod 600 wg_priv_key |
||
| 20 | chmod 600 wg_pub_key |
||
| 21 | </pre> |
||
| 22 | |||
| 23 | 5 | Michael Gunsch | Der private Schlüssel bleibt lokal, der öffentliche Schlüssel wird zum entfernten Partner übertragen. |
| 24 | |||
| 25 | h3. Konfigurationsdatei lokal |
||
| 26 | |||
| 27 | Die Konfigurationsdatei liegt in @/etc/wireguard/wg0.conf@, wobei anstelle der Null eine beliebige Zahl stehen darf. Dieser Name – im Beispiel @wg0@ – ist auch der Name der Netzwerkschnittstelle, die von WireGuard angelegt wird. |
||
| 28 | |||
| 29 | 6 | Michael Gunsch | /etc/wireguard/wg0.conf |
| 30 | |||
| 31 | 5 | Michael Gunsch | <pre> |
| 32 | [Interface] |
||
| 33 | PrivateKey = <insert private key here> |
||
| 34 | Address = 172.16.4.8/24 |
||
| 35 | |||
| 36 | [Peer] |
||
| 37 | PublicKey = <insert peer's public key here> |
||
| 38 | AllowedIPs = 172.16.4.0/24 |
||
| 39 | Endpoint = puntodivista.ch:51820 |
||
| 40 | PersistentKeepalive = 25 |
||
| 41 | 1 | Michael Gunsch | </pre> |
| 42 | 7 | Michael Gunsch | |
| 43 | 1 | Michael Gunsch | h3. Konfigurationsdatei entfernt |
| 44 | 8 | Michael Gunsch | |
| 45 | /etc/wireguard/wg0.conf |
||
| 46 | |||
| 47 | <pre> |
||
| 48 | [Interface] |
||
| 49 | Address = 172.16.4.1/24 |
||
| 50 | PrivateKey = <insert private key here> |
||
| 51 | ListenPort = 51820 |
||
| 52 | |||
| 53 | # Sample client |
||
| 54 | [Peer] |
||
| 55 | PublicKey = <insert peer's public key here> |
||
| 56 | AllowedIPs = 172.16.4.2 |
||
| 57 | </pre> |
||
| 58 | 9 | Michael Gunsch | |
| 59 | h3. VPN manuell starten/stoppen |
||
| 60 | |||
| 61 | <pre> |
||
| 62 | sudo wg-quick up wg0 |
||
| 63 | sudo wg-quick down wg0 |
||
| 64 | </pre> |
||
| 65 | |||
| 66 | h3. Automatischer Start über @systemctl@ |
||
| 67 | |||
| 68 | <pre> |
||
| 69 | sudo systemctl enable wg-quick@wg0 |
||
| 70 | sudo systemctl start wg-quick@wg0 |
||
| 71 | </pre> |