गाइड

VPS पर 5 मिनट में WireGuard VPN सेट करें

शुरुआती5 मिनट पढ़ेंअपडेट किया गया 30 मई 2026
संक्षिप्त उत्तर

काम करने वाले WireGuard सर्वर के लिए चार चीज़ें चाहिए: कुंजी जोड़ी, wg0 इंटरफ़ेस कॉन्फ़िगरेशन, IP फ़ॉरवर्डिंग NAT के साथ, और प्रति डिवाइस एक पीयर ब्लॉक। $4 इंस्टेंस पर पूरी प्रक्रिया लगभग पाँच मिनट लेती है और एक गीगाबिट पोर्ट को संतृप्त कर देगी।

01 WireGuard स्थापित करें और कुंजी उत्पन्न करें

The kernel module is already present on any modern Linux distribution running on KVM.

apt update && apt install -y wireguard
umask 077
wg genkey | tee /etc/wireguard/server.key | wg pubkey > /etc/wireguard/server.pub

02 सर्वर कॉन्फ़िगरेशन लिखें

Replace eth0 with your actual interface name if it differs — check with ip -br link. The Address line defines the tunnel subnet, not your public address.

# /etc/wireguard/wg0.conf
[Interface]
Address = 10.66.66.1/24, fd42:42::1/64
ListenPort = 51820
PrivateKey = <contents of /etc/wireguard/server.key>
PostUp   = nft add table ip nat; nft add chain ip nat post { type nat hook postrouting priority 100 \; }; nft add rule ip nat post oifname "eth0" masquerade
PostDown = nft delete table ip nat

03 फ़ॉरवर्डिंग सक्षम करें और टनल शुरू करें

Forwarding must be enabled for both address families, or IPv6 clients will fail silently.

cat >/etc/sysctl.d/99-wg.conf <<'EOF'
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
EOF
sysctl --system
systemctl enable --now wg-quick@wg0
ufw allow 51820/udp

04 प्रत्येक डिवाइस के लिए एक पीयर जोड़ें

Generate a key pair per device. AllowedIPs on the server side is the address that device will hold inside the tunnel — not a range.

wg set wg0 peer <CLIENT_PUBLIC_KEY> allowed-ips 10.66.66.2/32,fd42:42::2/128
wg-quick save wg0

05 क्लाइंट कॉन्फ़िगरेशन

AllowedIPs of 0.0.0.0/0 and ::/0 routes all traffic through the tunnel. Narrow it for split tunnelling.

[Interface]
PrivateKey = <client private key>
Address = 10.66.66.2/32, fd42:42::2/128
DNS = 10.66.66.1

[Peer]
PublicKey = <server public key>
Endpoint = YOUR_SERVER_IP:51820
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 25

अक्सर पूछे जाने वाले प्रश्न

एक VPS कितने डिवाइस संभाल सकता है?

एक साझा कोर आराम से 20+ समवर्ती पीयर संभालता है। सीमा आपका अपलिंक है, इंस्टेंस नहीं।

मेरा कनेक्शन धीमा क्यों है?

लगभग हमेशा MTU। क्लाइंट इंटरफ़ेस पर MTU = 1420 आज़माएं; WireGuard ओवरहेड जोड़ता है जो पैकेट को पथ MTU से आगे धकेल सकता है और फ़्रैगमेंटेशन ट्रिगर कर सकता है।