Fixing WireGuard VPN Internet on MikroTik (Complete Step-by-Step)

WireGuard VPN MikroTik‑এ কনফিগার করার পর handshake হচ্ছিল, টানেলের ভেতরে IP ping কাজ করছিল, কিন্তু VPN ক্লায়েন্টদের Internet একেবারেই কাজ করছিল না। শেষ পর্যন্ত যা করা হলো, তাতেই সমস্যা ফাইনালি fix হলো।


🔎 Problem Symptoms

  • Android WireGuard client সফলভাবে Connect হচ্ছিল (Handshake OK)।
  • Client থেকে ping 10.10.172.1 (MikroTik WireGuard interface IP) → কাজ করছিল।
  • কিন্তু:
    • ping 8.8.8.8 → timeout
    • ping google.com → timeout
  • Router থেকে /ping 8.8.8.8 src-address=10.10.172.1 দিলে timeout হচ্ছিল।
  • Sniffer এ দেখা যাচ্ছিল client থেকে request যাচ্ছে (DST: 8.8.8.8:53 / 443 etc.), কিন্তু reply আসছে না।

🛑 Root Cause Analysis

  1. Public IP লুপব্যাক ইন্টারফেসে দেওয়া ছিল (103.139.253.104)।

    • আসল uplink interface (WAN_INT) এ private IP: 10.23.24.74/30
    • তাই masquerade হলে source IP বাইরে যেত 10.23.24.74 → ISP সেটা drop করছিল।
    • ISP থেকে return আসবে শুধু Public IP (103.139.253.104) তে।
  2. Multiple default routes ছিল, যার মধ্যে Distance=1 route অন্য সেটআপে point করছিল → WG traffic ভুল gateway দিয়ে বের হচ্ছিল।


✅ Final Fix Steps

1. WireGuard Basic Setup

Server Interface:

text
/interface wireguard add name=wireguard listen-port=13231
/ip address add address=10.10.172.1/24 interface=wireguard

Peer Config (Android client public key অনুযায়ী):

text
/interface wireguard peers add interface=wireguard public-key=<client-pubkey> allowed-address=10.10.172.2/32

2. NAT Rule (Critical Fix)

WG subnet এর traffic public IP দিয়ে বের করতে NAT → SNAT use করতে হবে:

text
/ip firewall nat
add chain=srcnat src-address=10.10.172.0/24 out-interface=WAN_INT action=src-nat to-addresses=103.139.253.104 comment="WG Clients use Public IP"

👉 এর ফলে WG client এর traffic বাইরে গেলে সবসময় আপনার real public IP 103.139.253.104 দিয়ে যাবে। ফলে ISP return করবে।


3. Routing Rule (Ensure Correct Gateway)

WG subnet এর traffic কে সরাসরি WAN_INT gateway তে পাঠান:

text
/routing rule
add src-address=10.10.172.0/24 action=lookup-only-in-table table=main

And make sure main table has WAN_INT default route:

text
/ip route add dst-address=0.0.0.0/0 gateway=10.23.24.73 routing-table=main

4. Firewall Filter

WG subnet forward allow rules:

text
/ip firewall filter
add chain=forward src-address=10.10.172.0/24 action=accept comment="Allow WG OUT"
add chain=forward dst-address=10.10.172.0/24 action=accept comment="Allow WG IN"

5. DNS

Remote DNS enable করুন:

text
/ip dns set allow-remote-requests=yes servers=8.8.8.8,1.1.1.1

✅ Testing

  1. Router থেকে ping:
text
/ping 8.8.8.8 src-address=10.10.172.1

👉 এখন successful reply আসবে (~30ms)।

  1. Android থেকে:

    • ping 10.10.172.1 ✅
    • ping 8.8.8.8 ✅
    • ping google.com ✅
  2. Internet browsing now works through MikroTik + WireGuard tunnel.


📱 Android WireGuard Client Config

text
[Interface]
PrivateKey = <Client-Private-Key>
Address = 10.10.172.2/32
DNS = 8.8.8.8, 1.1.1.1

[Peer]
PublicKey = <MikroTik-Public-Key>
Endpoint = 103.139.253.104:13231
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25

🎯 Conclusion

👉 মূল সমস্যাটা NAT‑এ ছিল। WG subnet masquerade হচ্ছিল uplink এর private IP (10.23.24.74) দিয়ে, যেটা ISP drop করছিল।
Fix: WG subnet NAT করতে হবে loopback‑এ assign করা real Public IP (103.139.253.104) দিয়ে।

এবং routing rule যোগ করার পর থেকে WG traffic সবসময় WAN_INT gateway (10.23.24.73) দিয়ে বাইরে চলে গেছে।

ফলাফল: Android WG client এখন সফলভাবে ইন্টারনেট পাচ্ছে! 🚀


⭐ Key Takeaways

  • Public IP যদি loopback এ বসানো হয়, সব WG NAT rules এ সেই Public IP force করতে হবে।
  • Multiple default routes থাকলে WG subnet এর জন্য আলাদা routing rule দরকার।
  • Always test with:
    • /ping 8.8.8.8 src-address=<WG server IP>
    • Client side ping 8.8.8.8

ভাই, এই আর্টিকেলটাই আপনার final reference। এখন আর দ্বিধা থাকলো না — অন্য কেউ এই problem face করলে এই গাইড follow করলেই fix পাবে ✅


👉 Keypair কিভাবে বানাবেন (সিম্পল Safe Method)

Option–1: MikroTik দিয়েই বানাবেন

RouterOS‑এ WireGuard interface add করার সময় keypair auto বানায়। তাই test‑interface বানিয়ে keys নিয়ে নিন:

Bash
/interface wireguard add name=temp-wg
/interface wireguard print detail
  • Output এ:
    • private-key="XXXX..." → ওই রাউটার (যেটা key বানাতে পারে না) এর config এ ব্যবহার করবেন।
    • public-key="YYYY..." → MicroTik server‑এ peer হিসেবে বসাবেন।

তারপর temp-wg interface remove করে দিতে পারেন:

Bash
/interface wireguard remove temp-wg

Option–2: Linux / Windows PC দিয়ে বানান

যেকোনো PC/Server এ WireGuard tools ইন্সটল করে:

Bash
wg genkey | tee privatekey | wg pubkey > publickey
  • File privatekey → ওই client router config এ বসাবেন।
  • File publickey → MikroTik server এ peer হিসেবে add করবেন।

Option–3: Android এ WireGuard App দিয়েও বানানো যায়

WireGuard Android app install করে → “Add empty tunnel” → ওগুলো auto keypair generate করবে।

  • App এ দেখানো Private Key → client router config এ বসাবেন।
  • Public Key → MikroTik server peers এ।

🛠 Example Workflow: ধরুন নতুন Router যোগ করবেন

  1. Client এর জন্য keypair বানালেন (যে router নিজে বানাতে পারে না)

    • ধরুন BANGLA-Router এর জন্য বানানো হলো:
    text
    PrivateKey = AbCdEfGhIjKlMnOpqrstuvwxyz1234567=
    PublicKey  = ZYXWvuTsrqponmlkjihgfedcba9876543=
  2. MikroTik Server এ Peer Add করুন

    Bash
    /interface wireguard peers add \
        interface=wireguard \
        public-key="ZYXWvuTsrqponmlkjihgfedcba9876543=" \
        allowed-address=10.10.172.4/32
  3. Client Router Config বানিয়ে দিন (এটা manually লিখে config file আকারে upload করবেন)
    যেমন router.conf:

    ini
    [Interface]
    PrivateKey = AbCdEfGhIjKlMnOpqrstuvwxyz1234567=
    Address = 10.10.172.4/32
    DNS = 8.8.8.8, 1.1.1.1
    
    [Peer]
    PublicKey = DkDewMH07LwBj+WLiarcL/2Sj3t39LWzZCWptwqUYwU=   # Server Public Key
    Endpoint  = 103.139.253.104:13231
    AllowedIPs = 0.0.0.0/0
    PersistentKeepalive = 25

    👉 এই config ফাইল ওই dumb-router এর WebUI তে upload করুন (যেখানে শুধু “Upload WireGuard Config” অপশন আছে)।


🎯 Summary

  • Router নিজে keypair বানাতে না পারলে, আপনি MikroTik / Linux / অন্য client app দিয়ে আগে keypair বানাবেন
  • PrivateKey → Client Router এ
  • PublicKey → MikroTik server peer config এ
  • সবসময় unique IP (10.10.172.X/32) দেবেন

About the author

Riazul Islam
Expert IT support for seamless, innovative operations.

Post a Comment