VPN pada MikroTik: Site-to-Site & Remote Access

TOKEN
๐Ÿ“… 25 Juni 2026
๐Ÿ“– 15 menit baca
Lanjut
๐ŸŒ MikroTik

1. Jenis-Jenis VPN

VPN (Virtual Private Network) adalah teknologi yang memungkinkan koneksi aman melalui jaringan publik (internet). MikroTik RouterOS mendukung berbagai protokol VPN yang bisa dipilih sesuai kebutuhan โ€” dari yang legacy hingga yang modern.

Perbandingan Protokol VPN di MikroTik

โš ๏ธ
PPTP
  • โœ… Konfigurasi paling mudah
  • โœ… Built-in di hampir semua OS
  • โš ๏ธ Keamanan lemah (MPPE 128-bit)
  • โš ๏ธ Tidak direkomendasikan untuk produksi
๐Ÿ”’
L2TP/IPSec
  • โœ… Keamanan kuat (AES-256)
  • โœ… Kompatibel dengan semua OS
  • โœ… Standar industri enterprise
  • โœ… NAT traversal didukung
๐Ÿš€
WireGuard
  • โœ… Performa terbaik (kernel space)
  • โœ… Konfigurasi sederhana (key-based)
  • โœ… Low latency & fast roaming
  • โœ… Modern & secure (ChaCha20)
Fitur PPTP L2TP/IPSec WireGuard
Enkripsi MPPE 128-bit AES-256 ChaCha20 + Poly1305
Port TCP 1723 UDP 500, 4500 UDP (configurable)
Throughput Sedang Sedang-Baik Tinggi
NAT Traversal Masalah Baik Sangat baik
Rekomendasi โš ๏ธ Legacy/testing saja โœ… Produksi โœ… Pilihan utama
โš ๏ธ Keamanan PPTP

PPTP sudah lama dianggap tidak aman dan bisa dipecah dalam hitungan menit. Gunakan PPTP hanya untuk testing atau skenario legacy. Untuk produksi, gunakan L2TP/IPSec atau WireGuard.

2. PPTP Setup

PPTP (Point-to-Point Tunneling Protocol) adalah VPN tertua yang didukung MikroTik. Meskipun keamanannya lemah, konfigurasinya sangat mudah dan cocok untuk belajar konsep dasar VPN.

Server PPTP di MikroTik

MikroTik CLI โ€” PPTP Server
# Step 1: Aktifkan PPTP Server
/interface pptp-server server
set enabled=yes default-mtu=1460 default-mru=1460 \
    authentication=mschap2 keepalive-timeout=30

# Step 2: Buat IP Pool untuk VPN client
/ip pool
add name=pptp-pool ranges=192.168.100.10-192.168.100.50

# Step 3: Buat PPP Profile
/ppp profile
add name=pptp-profile local-address=192.168.100.1 \
    remote-address=pptp-pool dns-server=8.8.8.8,8.8.4.4 \
    use-encryption=yes use-compression=no

# Step 4: Tambah user VPN
/ppp secret
add name=user1 password="KuatP@ss123!" service=pptp profile=pptp-profile
add name=user2 password="KuatP@ss456!" service=pptp profile=pptp-profile

# Step 5: Verifikasi
/interface pptp-server print
/ppp active print
      

Client PPTP di MikroTik

MikroTik CLI โ€” PPTP Client
# Tambah PPTP Client
/interface pptp-client
add name=pptp-out1 connect-to=203.0.113.1 \
    user=user1 password="KuatP@ss123!" \
    profile=default-encryption \
    add-default-route=no disabled=no

# Verifikasi koneksi
/interface pptp-client print detail
/ppp active print

# Tambahkan route melalui VPN tunnel
/ip route add dst-address=192.168.1.0/24 gateway=pptp-out1
      

3. L2TP/IPSec

L2TP/IPSec adalah kombinasi dari L2TP (Layer 2 Tunneling Protocol) untuk tunneling dan IPSec untuk enkripsi. Ini adalah solusi VPN standar industri yang didukung oleh semua OS modern โ€” Windows, macOS, Linux, iOS, dan Android.

Server L2TP/IPSec di MikroTik

MikroTik CLI โ€” L2TP/IPSec Server
# Step 1: Buat IP Pool
/ip pool
add name=l2tp-pool ranges=192.168.200.10-192.168.200.100

# Step 2: Buat PPP Profile
/ppp profile
add name=l2tp-profile local-address=192.168.200.1 \
    remote-address=l2tp-pool dns-server=1.1.1.1,8.8.8.8 \
    use-encryption=required use-compression=no

# Step 3: Konfigurasi IPSec
/ip ipsec profile
add name=l2tp-profile hash-algorithm=sha256 \
    enc-algorithm=aes-256 dh-group=modp2048 \
    lifetime=8h nat-traversal=yes dpd-interval=120s \
    dpd-maximum-failures=5

/ip ipsec peer
add exchange-mode=main-l2tp passive=yes \
    profile=l2tp-profile send-initial-contact=yes

/ip ipsec proposal
set [ find default=yes ] auth-algorithms=sha256 \
    enc-algorithms=aes-256-cbc lifetime=8h pfs-group=none

# Step 4: Aktifkan L2TP Server
/interface l2tp-server server
set enabled=yes default-profile=l2tp-profile \
    authentication=mschap2 use-ipsec=required \
    ipsec-secret="IPSecK3yStr0ng!" \
    max-mtu=1400 max-mru=1400

# Step 5: Tambah user
/ppp secret
add name=admin1 password="VpnS3cur3P@ss!" service=l2tp profile=l2tp-profile
add name=staff1 password="St4ffVpn2026!" service=l2tp profile=l2tp-profile
      
๐Ÿ’ก Konfigurasi Client L2TP/IPSec

Pada perangkat client (Windows/macOS/Android/iOS), buat VPN baru dengan tipe L2TP/IPSec. Masukkan server IP, username, password, dan IPSec pre-shared key sesuai konfigurasi di atas. Pastikan port UDP 500, UDP 4500, dan UDP 1701 tidak diblokir oleh firewall.

4. WireGuard

WireGuard adalah protokol VPN modern yang sangat cepat, ringan, dan mudah dikonfigurasi. MikroTik RouterOS v7 mendukung WireGuard secara native. WireGuard menggunakan kriptografi mutakhir (Curve25519, ChaCha20, Poly1305) dan berjalan di kernel space untuk performa maksimal.

Server WireGuard di MikroTik

๐Ÿ”„ Langkah Konfigurasi WireGuard
1

Buat WireGuard Interface

Buat interface WireGuard โ€” keypair otomatis di-generate.

2

Assign IP Address

Berikan IP address pada interface WireGuard (biasanya /24 atau /30).

3

Tambah Peer

Setiap client ditambahkan sebagai peer dengan public key dan allowed-ips.

4

Firewall & Routing

Allow port UDP WireGuard dan tambahkan routing yang diperlukan.

MikroTik CLI โ€” WireGuard Server
# Step 1: Buat WireGuard interface (keypair auto-generated)
/interface wireguard
add name=wg0 listen-port=51820 \
    comment="WireGuard VPN Server"

# Cek public key (dibutuhkan untuk konfigurasi client)
/interface wireguard print detail
# Catat public key, contoh: aBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890abcde=

# Step 2: Assign IP address
/ip address
add address=10.10.10.1/24 interface=wg0 comment="WireGuard VPN Subnet"

# Step 3: Tambah peer untuk client
/interface wireguard peers
# Client 1 - Laptop Admin
add interface=wg0 \
    public-key="CLIENT_PUBLIC_KEY_DISINI=" \
    allowed-address=10.10.10.2/32 \
    comment="Admin Laptop"

# Client 2 - Handphone Staff
add interface=wg0 \
    public-key="CLIENT2_PUBLIC_KEY_DISINI=" \
    allowed-address=10.10.10.3/32 \
    comment="Staff Phone"

# Step 4: Firewall - Allow WireGuard port
/ip firewall filter
add chain=input protocol=udp dst-port=51820 action=accept \
    comment="Allow WireGuard" place-before=0
      

Client WireGuard (Laptop/HP)

WireGuard Client Config
# Config untuk WireGuard client (file .conf)
[Interface]
PrivateKey = 
Address = 10.10.10.2/24
DNS = 1.1.1.1, 8.8.8.8

[Peer]
PublicKey = 
Endpoint = 203.0.113.1:51820
AllowedIPs = 0.0.0.0/0    # Route semua traffic ke VPN (full tunnel)
# AllowedIPs = 10.10.10.0/24, 192.168.1.0/24  # Split tunnel
PersistentKeepalive = 25
      
โœ… Tips: WireGuard NAT Traversal

WireGuard sangat baik dalam menangani NAT. Tambahkan PersistentKeepalive = 25 pada client agar tunnel tetap aktif meskipun tidak ada traffic. Ini sangat penting untuk koneksi mobile yang sering berpindah jaringan (WiFi โ†” 4G).

5. Site-to-Site VPN

Site-to-Site VPN menghubungkan dua kantor/cabang secara permanen melalui tunnel VPN. Semua perangkat di kedua lokasi bisa saling berkomunikasi seolah berada di jaringan yang sama. Ini sangat cocok untuk perusahaan dengan beberapa cabang.

Topologi Site-to-Site VPN

๐Ÿ“Š Site-to-Site WireGuard VPN
๐Ÿข
Kantor Pusat
192.168.1.0/24 ยท MikroTik A
โ†’
๐Ÿ”’
WireGuard Tunnel
10.10.10.0/30 ยท Encrypted
โ†’
๐Ÿญ
Kantor Cabang
192.168.2.0/24 ยท MikroTik B

Konfigurasi MikroTik A (Kantor Pusat โ€” Server)

MikroTik CLI โ€” Site-to-Site Server (Pusat)
# WireGuard interface
/interface wireguard
add name=wg-s2s listen-port=51820 comment="Site-to-Site VPN"

# IP pada tunnel
/ip address
add address=10.10.10.1/30 interface=wg-s2s comment="S2S Tunnel"

# Peer: Kantor Cabang
/interface wireguard peers
add interface=wg-s2s \
    public-key="=" \
    allowed-address=10.10.10.2/32,192.168.2.0/24 \
    endpoint=198.51.100.1:51820 \
    comment="Kantor Cabang"

# Route ke jaringan cabang via tunnel
/ip route
add dst-address=192.168.2.0/24 gateway=wg-s2s \
    comment="Route ke Cabang via VPN"

# Firewall: Allow WireGuard
/ip firewall filter
add chain=input protocol=udp dst-port=51820 action=accept \
    comment="Allow WireGuard S2S" place-before=0

# NAT: Jangan NAT traffic ke cabang
/ip firewall nat
add chain=srcnat dst-address=192.168.2.0/24 action=accept \
    comment="No NAT to Branch" place-before=0
      

Konfigurasi MikroTik B (Kantor Cabang โ€” Client)

MikroTik CLI โ€” Site-to-Site Client (Cabang)
# WireGuard interface
/interface wireguard
add name=wg-s2s listen-port=51820 comment="Site-to-Site VPN"

# IP pada tunnel
/ip address
add address=10.10.10.2/30 interface=wg-s2s comment="S2S Tunnel"

# Peer: Kantor Pusat
/interface wireguard peers
add interface=wg-s2s \
    public-key="=" \
    allowed-address=10.10.10.1/32,192.168.1.0/24 \
    endpoint=203.0.113.1:51820 \
    persistent-keepalive=25 \
    comment="Kantor Pusat"

# Route ke jaringan pusat via tunnel
/ip route
add dst-address=192.168.1.0/24 gateway=wg-s2s \
    comment="Route ke Pusat via VPN"

# NAT: Jangan NAT traffic ke pusat
/ip firewall nat
add chain=srcnat dst-address=192.168.1.0/24 action=accept \
    comment="No NAT to HQ" place-before=0
      

6. Remote Access VPN

Remote Access VPN memungkinkan karyawan/teknisi mengakses jaringan kantor dari lokasi manapun melalui internet. Berbeda dengan site-to-site yang menghubungkan dua jaringan, remote access menghubungkan satu perangkat ke jaringan.

Skema Remote Access dengan WireGuard

MikroTik CLI โ€” Remote Access WireGuard
# WireGuard interface (sudah dibuat di section sebelumnya)
# /interface wireguard add name=wg0 listen-port=51820

# IP Pool untuk remote users
/ip pool
add name=wg-pool ranges=10.10.10.2-10.10.10.254

# Profile untuk assign IP (opsional, atau assign manual per peer)
# Setiap user mendapat IP tetap di allowed-address

# Tambah user remote access
/interface wireguard peers
# Remote user 1
add interface=wg0 \
    public-key="=" \
    allowed-address=10.10.10.10/32 \
    comment="Remote - Admin Andi"

# Remote user 2
add interface=wg0 \
    public-key="=" \
    allowed-address=10.10.10.11/32 \
    comment="Remote - Staff Budi"

# Firewall: Allow traffic dari VPN ke LAN
/ip firewall filter
add chain=forward in-interface=wg0 dst-address=192.168.1.0/24 action=accept \
    comment="Allow VPN to LAN"

# DNS untuk VPN clients (opsional, gunakan AdGuard/PIHole)
/ip dns
set allow-remote-requests=yes
      

Koneksi dari Windows/macOS/Linux

Terminal โ€” Client Setup
# Install WireGuard client
# Windows: https://www.wireguard.com/install/
# macOS: brew install wireguard-tools
# Linux: sudo apt install wireguard

# Generate keypair pada client
wg genkey | tee privatekey | wg pubkey > publickey

# Buat config file (wg0.conf)
cat > wg0.conf << EOF
[Interface]
PrivateKey = 
Address = 10.10.10.10/24
DNS = 10.10.10.1

[Peer]
PublicKey = 
Endpoint = 203.0.113.1:51820
AllowedIPs = 192.168.1.0/24, 10.10.10.0/24
PersistentKeepalive = 25
EOF

# Aktifkan tunnel
sudo wg-quick up wg0

# Verifikasi
wg show
ping 192.168.1.1
      

7. Firewall Rules untuk VPN

Konfigurasi firewall yang tepat sangat penting untuk keamanan VPN. Kita perlu memastikan port VPN terbuka, traffic terisolasi dengan benar, dan tidak ada kebocoran data.

MikroTik CLI โ€” Firewall VPN Rules
# ===== INPUT CHAIN =====
# Allow WireGuard
/ip firewall filter
add chain=input protocol=udp dst-port=51820 action=accept \
    comment="Allow WireGuard VPN" place-before=0

# Allow L2TP/IPSec
add chain=input protocol=udp dst-port=500 action=accept \
    comment="Allow IKE (IPSec)" place-before=0
add chain=input protocol=udp dst-port=4500 action=accept \
    comment="Allow NAT-T (IPSec)" place-before=0
add chain=input protocol=udp dst-port=1701 action=accept \
    comment="Allow L2TP" place-before=0
add chain=input protocol=ipsec-esp action=accept \
    comment="Allow IPSec ESP" place-before=0

# Allow PPTP (legacy)
add chain=input protocol=tcp dst-port=1723 action=accept \
    comment="Allow PPTP" place-before=0
add chain=input protocol=gre action=accept \
    comment="Allow GRE (PPTP)" place-before=0

# ===== FORWARD CHAIN =====
# Allow VPN clients akses ke LAN
add chain=forward in-interface=wg0 dst-address=192.168.1.0/24 action=accept \
    comment="VPN to LAN"
add chain=forward in-interface=wg0 out-interface=ether1 action=accept \
    comment="VPN to Internet"

# Allow established/related
add chain=forward connection-state=established,related action=accept \
    comment="Allow established"

# Drop invalid connections
add chain=forward connection-state=invalid action=drop \
    comment="Drop invalid"

# ===== NAT =====
# NAT untuk VPN clients ke internet (jika dibutuhkan)
/ip firewall nat
add chain=srcnat src-address=10.10.10.0/24 out-interface=ether1 action=masquerade \
    comment="NAT VPN clients to Internet"
      
โš ๏ธ Keamanan: Jangan Buka Semua Port

Hanya buka port yang benar-benar dibutuhkan untuk VPN. Jangan menambahkan rule accept all hanya karena "VPN tidak bisa connect" โ€” selalu cek log dan diagnosa masalahnya terlebih dahulu. Gunakan /log print where topics~"firewall" untuk melihat traffic yang diblokir.

8. Troubleshooting VPN

Berikut panduan troubleshooting untuk masalah VPN yang umum di MikroTik:

MikroTik CLI โ€” Troubleshooting VPN
# ===== WireGuard =====
# Cek interface WireGuard
/interface wireguard print detail
/interface wireguard peers print detail

# Cek handshake (last handshake harus dalam 2 menit terakhir)
/interface wireguard peers print stats

# Cek traffic
/interface monitor-traffic interface=wg0

# ===== L2TP/IPSec =====
# Cek PPP active connections
/ppp active print detail

# Cek IPSec SAs (Security Associations)
/ip ipsec active-peers print
/ip ipsec installed-sa print

# Debug IPSec
/system logging
add topics=ipsec action=memory

# Debug PPP
/system logging
add topics=ppp action=memory

# ===== PPTP =====
# Cek PPTP connections
/interface pptp-server print
/ppp active print

# ===== Umum =====
# Cek log untuk error
/log print where topics~"ppp" or topics~"ipsec" or topics~"wireguard"

# Ping test melalui tunnel
/ping 10.10.10.1 src-address=10.10.10.2 count=5

# Traceroute untuk memverifikasi path
/tool traceroute 192.168.1.100
      

Masalah Umum dan Solusi

Masalah Penyebab Solusi
WireGuard tidak bisa connect Port UDP diblokir firewall Allow UDP port 51820 di input filter
L2TP stuck di connecting IPSec phase 1 gagal Cek IPSec profile, pastikan pre-shared key cocok
VPN connect tapi tidak bisa akses LAN Route atau NAT belum dikonfigurasi Tambahkan route dan NAT exception rules
Speed VPN lambat MTU terlalu besar (fragmentation) Turunkan MTU ke 1400 atau kurangi MSS clamping
WireGuard handshake timeout Endpoint salah atau NAT issue Cek public IP, port, dan pastikan PersistentKeepalive=25
PPTP error 619 GRE protocol diblokir Allow GRE (protocol 47) di firewall

9. Quiz: Uji Pemahamanmu

Jawab pertanyaan berikut untuk menguji pemahaman kamu tentang VPN pada MikroTik. Pilih satu jawaban terbaik untuk setiap pertanyaan.

๐Ÿ“ Quiz VPN MikroTik

1. Mengapa WireGuard lebih cepat dibandingkan L2TP/IPSec?

2. Port UDP berapa yang digunakan WireGuard secara default?

3. Dalam konfigurasi Site-to-Site VPN, apa fungsi rule NAT exception?

4. Apa fungsi dari "allowed-address" pada konfigurasi WireGuard peer?

5. VPN client terhubung tapi tidak bisa mengakses jaringan internal. Apa langkah pertama troubleshooting?