docs(step1): add wireguard server/client scripts + reset guide
This commit is contained in:
116
doc/step-001-wireguard-tools.md
Normal file
116
doc/step-001-wireguard-tools.md
Normal file
@@ -0,0 +1,116 @@
|
||||
# Step 001A: WireGuard tools (server/client) + instrukcje reset
|
||||
|
||||
Ten step dodaje dwa skrypty pomocnicze do zarzadzania WireGuard:
|
||||
|
||||
- server: `scripts/wireguard/wg_serverctl.py`
|
||||
- client: `scripts/wireguard/wg_client.py`
|
||||
|
||||
Skrypty trzymaja stan na dysku, zgodnie z konwencja:
|
||||
|
||||
- server keys: `/etc/wireguard/server.key`, `/etc/wireguard/server.pub`
|
||||
- clients: `/etc/wireguard/clients/<name>.key|.pub|.ip|.conf`
|
||||
- generated server config: `/etc/wireguard/wg0.conf`
|
||||
|
||||
Wymagania: `wireguard-tools` (czyli `wg`, `wg-quick`) + `systemd`.
|
||||
|
||||
## Instalacja (server)
|
||||
|
||||
Na bare metalu:
|
||||
|
||||
```bash
|
||||
apt-get update
|
||||
apt-get install -y wireguard
|
||||
```
|
||||
|
||||
Z repo (na hoście) zainstaluj skrypt jako root-only:
|
||||
|
||||
```bash
|
||||
install -m 700 scripts/wireguard/wg_serverctl.py /usr/local/sbin/wg_serverctl.py
|
||||
```
|
||||
|
||||
## Instalacja (client)
|
||||
|
||||
Na kliencie (laptop/VPS):
|
||||
|
||||
```bash
|
||||
apt-get update
|
||||
apt-get install -y wireguard
|
||||
install -m 700 scripts/wireguard/wg_client.py /usr/local/sbin/wg_client.py
|
||||
```
|
||||
|
||||
## Typowy flow (server)
|
||||
|
||||
```bash
|
||||
# 1) wygeneruj klucze serwera
|
||||
wg_serverctl.py gen-server --force
|
||||
|
||||
# 2) wygeneruj klucze klienta (trzymane na serwerze w /etc/wireguard/clients)
|
||||
wg_serverctl.py gen-client client1
|
||||
|
||||
# 3) dodaj klienta do puli, wygeneruj wg0.conf i zrestartuj wg-quick@wg0
|
||||
wg_serverctl.py add client1
|
||||
|
||||
# 4) wyeksportuj client config (do przekazania na klienta)
|
||||
wg_serverctl.py export client1
|
||||
|
||||
# 5) podglad
|
||||
wg_serverctl.py list
|
||||
wg_serverctl.py show client1
|
||||
```
|
||||
|
||||
Plik konfiguracyjny klienta powstaje jako:
|
||||
|
||||
- `/etc/wireguard/clients/client1.conf`
|
||||
|
||||
## Typowy flow (client)
|
||||
|
||||
Skopiuj `client1.conf` na klienta, a potem:
|
||||
|
||||
```bash
|
||||
wg_client.py install ./client1.conf
|
||||
wg_client.py up
|
||||
wg_client.py status
|
||||
```
|
||||
|
||||
## Stop / disable / reset wg0 (Ubuntu 24.04)
|
||||
|
||||
Stop (zostaw config, tylko down):
|
||||
|
||||
```bash
|
||||
systemctl stop wg-quick@wg0
|
||||
```
|
||||
|
||||
Disable autostart:
|
||||
|
||||
```bash
|
||||
systemctl disable wg-quick@wg0
|
||||
```
|
||||
|
||||
Flush (pewny down + usuniecie interfejsu):
|
||||
|
||||
```bash
|
||||
systemctl stop wg-quick@wg0
|
||||
ip link del wg0 2>/dev/null || true
|
||||
ip a show wg0 2>/dev/null || echo "wg0 not present"
|
||||
```
|
||||
|
||||
Hard reset (usuniecie kluczy + konfiguracji):
|
||||
|
||||
```bash
|
||||
systemctl stop wg-quick@wg0
|
||||
systemctl disable wg-quick@wg0
|
||||
ip link del wg0 2>/dev/null || true
|
||||
|
||||
rm -f /etc/wireguard/wg0.conf
|
||||
rm -f /etc/wireguard/server.key /etc/wireguard/server.pub
|
||||
rm -rf /etc/wireguard/clients
|
||||
```
|
||||
|
||||
Reset peerow bez kasowania server key:
|
||||
|
||||
```bash
|
||||
systemctl stop wg-quick@wg0
|
||||
rm -f /etc/wireguard/clients/*.pub /etc/wireguard/clients/*.ip
|
||||
systemctl start wg-quick@wg0
|
||||
```
|
||||
|
||||
@@ -194,5 +194,5 @@ EOF
|
||||
## 5) Co dalej
|
||||
|
||||
- Instalacja i uruchomienie Agave: patrz `doc/etap-007-manual-baremetal-rpc-commands.md`.
|
||||
- Narzedzia do generowania konfiguracji WireGuard (server/client) + reset wg0: patrz `doc/step-001-wireguard-tools.md`.
|
||||
- Docelowo: bind RPC/WS do WG IP (zamiast `0.0.0.0`) i spójne, minimalne reguły firewall.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user