Zamonaviy VPN ยท 45 daqiqa
Mundarija
WireGuard
1. Nega WireGuard?
| IPsec | OpenVPN | WireGuard | |
|---|---|---|---|
| Kod hajmi | ~400 000 qator | ~100 000 | ~4 000 |
| Transport | ESP/UDP 500/4500 | UDP/TCP | UDP |
| Kriptografiya | Kelishiladi (ko'p variant) | TLS | Qat'iy: Curve25519, ChaCha20-Poly1305, BLAKE2s |
| Tezlik | Yuqori | O'rta | Juda yuqori (kernel) |
| Sozlash | Murakkab | O'rta | Sodda |
2. Asosiy tushunchalar
- Har bir tomonda kalit juftligi (private/public), SSH kalitlariga o'xshab.
- Peer = ochiq kalit + (ixtiyoriy) endpoint + AllowedIPs.
- Cryptokey routing: chiqishda โ paket manzili qaysi peerning AllowedIPs iga tushsa, o'sha peerga shifrlab yuboriladi; kirishda โ shifr ochilgandan keyin manba IP shu peerning AllowedIPs ida bo'lmasa, tashlanadi.
- WireGuard "jim" โ handshake bo'lmaguncha hech narsa yubormaydi, skanerlarda ko'rinmaydi.
3. wg-quick konfiguratsiyasi
# /etc/wireguard/wg0.conf โ VPS (public IP)
[Interface]
Address = 10.99.0.1/24
ListenPort = 51820
PrivateKey = <VPS_PRIVATE>
[Peer]
# home server (CGNAT ortida)
PublicKey = <HOME_PUBLIC>
AllowedIPs = 10.99.0.2/32
# /etc/wireguard/wg0.conf โ Home server
[Interface]
Address = 10.99.0.2/24
PrivateKey = <HOME_PRIVATE>
MTU = 1412 # PPPoE (1492) โ WireGuard overhead (80)
[Peer]
PublicKey = <VPS_PUBLIC>
Endpoint = vps.example.uz:51820
AllowedIPs = 10.99.0.1/32
PersistentKeepalive = 25
systemctl enable --now wg-quick@wg0
wg show
4. MTU โ eng ko'p uchraydigan muammo
WireGuard overhead: IPv4 da 60 bayt, IPv6 da 80 bayt. PPPoE ustida: 1492 โ 80 = 1412. Noto'g'ri MTU belgisi:
ping ishlaydi, lekin SSH/HTTPS "osilib" qoladi.
5. Amaliyot
Labda ikki "filial" orasida qo'lda (wg-quick siz) tunnel ko'tarasiz โ bu sizga har bir parametrni tushunishga yordam beradi.
๐งช Amaliy laboratoriya: WireGuard site-to-site tunnel
"Internet" (203.0.113.0/24) orqali ikki filial orasida WireGuard tunnel qurish: kalitlar, peer, AllowedIPs.
Tugunlar: site-a, site-b ยท ~45 daqiqa ยท 3 ta avto-tekshiruv