From e6d74db358aeb0828f98f60950235d78f133aeed Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sat, 19 Nov 2022 13:54:51 +0300 Subject: [PATCH] wg dump --- content/posts/2022/wireguard/get-stats.md | 92 +++++++++++++++++++ .../ui-env-variables.md} | 0 .../unknown-device-type.md} | 0 3 files changed, 92 insertions(+) create mode 100644 content/posts/2022/wireguard/get-stats.md rename content/posts/2022/{wireguard-ui-env-variables.md => wireguard/ui-env-variables.md} (100%) rename content/posts/2022/{wireguard-unknown-device-type.md => wireguard/unknown-device-type.md} (100%) diff --git a/content/posts/2022/wireguard/get-stats.md b/content/posts/2022/wireguard/get-stats.md new file mode 100644 index 0000000..3136dce --- /dev/null +++ b/content/posts/2022/wireguard/get-stats.md @@ -0,0 +1,92 @@ +--- +title: "πŸ•ΈοΈ ΠŸΠΎΠ»ΡƒΡ‡Π΅Π½ΠΈΠ΅ статистики соСдинСний WireGuard" +date: 2022-11-19T13:29:41+03:00 +draft: false +tags: [tips, wireguard] +--- + +## ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€ статистики + +Бтатистику ΠΊΠ»ΠΈΠ΅Π½Ρ‚ΠΎΠ² WireGuard ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΠ»ΡƒΡ‡ΠΈΡ‚ΡŒ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ `show` ΡƒΡ‚ΠΈΠ»ΠΈΡ‚Ρ‹ `wg`. + +НапримСр: + +```sh +wg show all +``` + +Команда Π²Π΅Ρ€Π½Ρ‘Ρ‚ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠΉ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚. + +```text +interface: wg0 + public key: + private key: (hidden) + listening port: 443 + +peer: + preshared key: (hidden) + endpoint: : + allowed ips: 10.253.1.2/32 + latest handshake: 5 seconds ago + transfer: 25.47 MiB received, 282.28 MiB sent + +peer: + preshared key: (hidden) + endpoint: : + allowed ips: 10.253.1.1/32 + latest handshake: 47 seconds ago + transfer: 314.81 MiB received, 776.23 MiB sent + +peer: + preshared key: (hidden) + allowed ips: 10.253.1.3/32 +``` + +Если Π½Π° машинС нСсколько интСрфСйсов WireGuard, +ΠΌΠΎΠΆΠ½ΠΎ вывСсти статистику ΠΏΠΎ ΠΊΠΎΠ½ΠΊΡ€Π΅Ρ‚Π½ΠΎΠΌΡƒ интСрфСйсу: + +```sh +wg show wg0 +``` + +Для наблюдСния Π·Π° статистикой Π² Ρ€Π΅Π°Π»ΡŒΠ½ΠΎΠΌ Π²Ρ€Π΅ΠΌΠ΅Π½ΠΈ +ΠΌΠΎΠΆΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ ΠΊΠΎΠΌΠ°Π½Π΄Ρƒ `watch`. + +```sh +watch wg show all +``` + +Or: + +`wg-json` tool from +[wireguard-tools](https://git.zx2c4.com/wireguard-tools/tree/contrib/json/wg-json). + +## Π‘Π±ΠΎΡ€ статистики + +Для сбора (Π΄Π°ΠΌΠΏΠ°) статистики Ρƒ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ Π΄ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ Π°Ρ€Π³ΡƒΠΌΠ΅Π½Ρ‚ `dump` +ΠΈ Π² Ρ‚Π΅Ρ€ΠΌΠΈΠ½Π°Π»Π΅ отобразится информация Π² Π²ΠΈΠ΄Π΅ Ρ‚Π°Π±Π»ΠΈΡ†Ρ‹: + +```sh +wg show all dump +``` + +```text +wg0 +wg0 +wg0 +wg0 +``` + +\* [wg.8.en.html#show](https://manpages.debian.org/unstable/wireguard-tools/wg.8.en.html#show) +on Debian man pages. + +## wg-json + +Π’ ΠΎΡ„ΠΈΡ†ΠΈΠ°Π»ΡŒΠ½Ρ‹ΠΉ состав инструмСнтов [wireguard-tools](https://git.zx2c4.com/wireguard-tools) +Π²Ρ…ΠΎΠ΄ΠΈΡ‚ ΡƒΡ‚ΠΈΠ»ΠΈΡ‚Π° **[wg-json](https://git.zx2c4.com/wireguard-tools/tree/contrib/json/wg-json)**. + +[Она](https://git.zx2c4.com/wireguard-tools/tree/contrib/json/wg-json) +прСдставляСт ΠΈΠ· сСбя Bash скрипт, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ ΠΏΡ€Π΅ΠΎΠ±Ρ€Π°Π·ΠΎΠ²Ρ‹Π²Π°Π΅Ρ‚ Π²Ρ‹Π²ΠΎΠ΄ ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹ +`wg show all dump` Π² JSON ΠΈ Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ Π΅Π³ΠΎ Π² Ρ‚Π΅Ρ€ΠΌΠΈΠ½Π°Π». + +Π£Ρ‚ΠΈΠ»ΠΈΡ‚Π° Π½Π΅ ΠΏΡ€ΠΈΠ½ΠΈΠΌΠ°Π΅Ρ‚ Π½ΠΈΠΊΠ°ΠΊΠΈΡ… Π°Ρ€Π³ΡƒΠΌΠ΅Π½Ρ‚ΠΎΠ². Π—Π°ΠΏΡƒΡΠΊΠ°Ρ‚ΡŒ ΠΊΠ°ΠΊ Π΅ΡΡ‚ΡŒ. diff --git a/content/posts/2022/wireguard-ui-env-variables.md b/content/posts/2022/wireguard/ui-env-variables.md similarity index 100% rename from content/posts/2022/wireguard-ui-env-variables.md rename to content/posts/2022/wireguard/ui-env-variables.md diff --git a/content/posts/2022/wireguard-unknown-device-type.md b/content/posts/2022/wireguard/unknown-device-type.md similarity index 100% rename from content/posts/2022/wireguard-unknown-device-type.md rename to content/posts/2022/wireguard/unknown-device-type.md