// IP ADDRESS ANDA SAAT INI
Mengambil informasi koneksi…
Buka Network Dashboard — Test Jaringan Kantor →

Skenario: kamu sysadmin atau developer Linux, butuh akses resource internal kantor sekaligus keluar dari IP publik kantor untuk testing API/whitelist. WireGuard via wg-quick sudah jalan, tapi cuma split tunnel — traceroute keluar dari ISP rumah, bukan dari perspektif kantor. Dua perubahan di /etc/wireguard/wg0.conf + verifikasi sisi server MikroTik = full tunnel jalan. Linux punya keunggulan tidak dimiliki Mac/Windows: bisa dijadikan systemd service untuk auto-connect saat boot, dan bisa kombinasi dengan cron + mtr untuk monitoring otomatis 24/7. Artikel ini cover tiga distro mainstream (Ubuntu/Debian, Fedora/RHEL, Arch) dan tiga skenario DNS handling.

WireGuard Full Tunnel di Linux
Ilustrasi: WireGuard Full Tunnel di Linux
Prasyarat sisi server: sebelum lanjut, pastikan MikroTik sudah dikonfigurasi full tunnel — lihat WireGuard Full Tunnel di MikroTik. Tanpa NAT masquerade di server, perubahan di Linux tidak akan jalan.

Split Tunnel vs Full Tunnel — Ringkas

Split tunnel = tunnel cuma untuk subnet internal kantor; traffic internet umum tetap lewat ISP rumah. Full tunnel = semua traffic IPv4/IPv6 lewat tunnel ke kantor lalu keluar via ISP kantor. Untuk penjelasan lengkap perbedaan + setup sisi server, lihat WireGuard Full Tunnel di MikroTik.

Prasyarat & Install WireGuard

<code>wg</code> dan <code>wg-quick</code> tersedia

Cek: which wg wg-quick. Kalau tidak ada, install dulu (perintah per distro di bawah).

Config di <code>/etc/wireguard/wg0.conf</code>

Pastikan sudah ada — file biasanya owned root, mode 600.

Peer terdaftar di server MikroTik

Public key Linux kamu sudah ada entry-nya di sisi server.

Split tunnel sudah connect

Test: sudo wg-quick up wg0 sukses, bisa ping IP internal kantor.

Server sudah full-tunnel-ready

AllowedAddress peer di MikroTik sudah include 0.0.0.0/0, dan NAT masquerade sudah ada — lihat artikel MikroTik.

Install WireGuard per Distro

Ubuntu / Debian (apt)
sudo apt update
sudo apt install -y wireguard wireguard-tools resolvconf

# resolvconf opsional tapi disarankan untuk DNS handling otomatis
Untuk Ubuntu 22.04+ yang pakai systemd-resolved by default, resolvconf tidak wajib — tapi kalau install, dia akan jadi backend yang dipakai wg-quick.
Fedora / RHEL / Rocky / AlmaLinux (dnf)
sudo dnf install -y wireguard-tools

# Fedora 37+: kernel module sudah built-in
# RHEL/Rocky/Alma 9+: enable EPEL dulu kalau belum:
# sudo dnf install -y epel-release
Fedora/RHEL pakai systemd-resolved, jadi tidak perlu resolvconf manual — wg-quick akan handle via resolvectl.
Arch / Manjaro / EndeavourOS (pacman)
sudo pacman -S --needed wireguard-tools

# Arch sudah pakai systemd-resolved by default — DNS otomatis handled
Arch official repo punya wireguard-tools terbaru. Tidak perlu AUR.

Langkah 1 — Edit /etc/wireguard/wg0.conf

Buka editor
sudo nano /etc/wireguard/wg0.conf
# atau
sudo vim /etc/wireguard/wg0.conf
File ini owned root, mode 600 — wajib sudo. Kalau permission longgar, tutup dulu: sudo chmod 600 /etc/wireguard/wg0.conf.
SEBELUM — Split Tunnel
[Interface]
PrivateKey = YOUR_PRIVATE_KEY
Address = 10.20.20.2/32

[Peer]
PublicKey = SERVER_PUBLIC_KEY
Endpoint = 103.10.x.x:51820
AllowedIPs = 10.20.20.0/24, 10.1.0.0/16
PersistentKeepalive = 25
SESUDAH — Full Tunnel
[Interface]
PrivateKey = YOUR_PRIVATE_KEY
Address = 10.20.20.2/32
DNS = 103.10.x.x, 8.8.8.8       # ← TAMBAH baris ini

[Peer]
PublicKey = SERVER_PUBLIC_KEY
Endpoint = 103.10.x.x:51820
AllowedIPs = 0.0.0.0/0, ::/0    # ← UBAH
PersistentKeepalive = 25
Save (Ctrl+O di nano, :wq di vim). Apply perubahan dengan restart tunnel — perintah di bawah.
Apply Config Baru
# Restart tunnel — wg-quick reload tidak ada, harus down dan up
sudo wg-quick down wg0
sudo wg-quick up wg0

# Verifikasi tunnel up dengan config baru
sudo wg show
wg show menampilkan: interface, peer, latest handshake, transfer stats. Kalau "latest handshake" recent (

DNS di Linux — Tiga Skenario Handling

DNS adalah bagian paling tricky di Linux karena beda per distro. Pilih skenario yang sesuai dengan stack DNS sistem kamu.

Skenario A — resolvconf

Kalau distro kamu pakai resolvconf (Ubuntu lama, Debian default, Mint), wg-quick otomatis handle baris DNS = via resolvconf — tidak perlu setup tambahan. Cek apakah tersedia:

Skenario A — resolvconf
which resolvconf
# /usr/sbin/resolvconf  ← tersedia

# Kalau tidak ada output, install:
sudo apt install -y resolvconf
Setelah resolvconf terinstall, baris DNS = ... di wg0.conf otomatis di-apply saat wg-quick up.

Skenario B — systemd-resolved

Distro modern (Ubuntu 18.04+, Fedora, Arch, openSUSE) pakai systemd-resolved. wg-quick otomatis handle via resolvectl. Verifikasi:

Skenario B — systemd-resolved
# Cek apakah aktif
systemctl is-active systemd-resolved
# active  ← OK

# Cek setting saat tunnel up
resolvectl status wg0
# Link 5 (wg0)
#   Current Scopes: DNS
#   DNS Servers: 103.10.x.x 8.8.8.8
#   ← muncul setelah wg-quick up wg0
Kalau systemd-resolved aktif, tidak perlu setup apapun di config — wg-quick deteksi dan apply otomatis.

Skenario C — Manual /etc/resolv.conf

Kalau dua di atas tidak tersedia (mis. distro minimal, container, custom build), pakai PostUp/PreDown hook di config untuk override /etc/resolv.conf:

Skenario C — Manual via PostUp/PreDown
[Interface]
PrivateKey = YOUR_PRIVATE_KEY
Address = 10.20.20.2/32
# DNS = ... ← HAPUS atau comment, pakai PostUp di bawah
PostUp = cp /etc/resolv.conf /etc/resolv.conf.wg-backup; echo -e 'nameserver 103.10.x.x\nnameserver 8.8.8.8' > /etc/resolv.conf
PreDown = mv /etc/resolv.conf.wg-backup /etc/resolv.conf

[Peer]
...
PostUp jalan setelah tunnel up, PreDown jalan sebelum down — DNS otomatis kembali normal saat tunnel mati. Backup ke .wg-backup mencegah data loss kalau system crash saat tunnel jalan.

Langkah 2 — Pastikan Server MikroTik Sudah Siap

Sebelum cek hasil di Linux, sisi server butuh dua hal: (1) AllowedAddress peer kamu di MikroTik sudah include 0.0.0.0/0, (2) NAT masquerade rule untuk subnet WireGuard ke interface WAN. Detail lengkap + troubleshooting di WireGuard Full Tunnel di MikroTik.

Langkah 3 — Verifikasi

Verifikasi via Terminal
# Test 1 — IP publik
curl ifconfig.me
# Harus return IP kantor

# Test 2 — MTR (mtr biasanya pre-installed)
sudo mtr --report --report-cycles 100 8.8.8.8
# Hop 2 harus gateway ISP kantor

# Test 3 — DNS resolusi via tunnel
cat /etc/resolv.conf
# nameserver harus IP kantor atau 8.8.8.8

# Test 4 — handshake terbaru
sudo wg show
# latest handshake: <2 minutes ago
Untuk cara baca output MTR (StDev, Wrst, Loss%), lihat Threshold Normal MTR — Cara Baca StDev & Wrst.

Bonus — WireGuard sebagai systemd Service (Auto-Connect saat Boot)

Untuk workstation Linux yang selalu butuh full tunnel — misal server monitoring atau workstation kantor di rumah — jadikan WireGuard auto-start saat boot. wg-quick punya unit systemd template built-in:

Enable & Start systemd Service
# Enable agar auto-start saat boot
sudo systemctl enable wg-quick@wg0

# Start sekarang juga (kalau belum jalan)
sudo systemctl start wg-quick@wg0

# Cek status
sudo systemctl status wg-quick@wg0
# ● [email protected] - WireGuard via wg-quick(8) for wg0
#    Loaded: loaded
#    Active: active (exited)

# Cek log kalau ada masalah
sudo journalctl -u wg-quick@wg0 -n 50
Format wg-quick@<name>, di mana <name> = nama interface tanpa .conf. Kalau punya beberapa tunnel, bisa enable terpisah: wg-quick@wg0, wg-quick@wg-office, dll.
Disable / Stop Service
# Stop sekarang
sudo systemctl stop wg-quick@wg0

# Disable auto-start saat boot
sudo systemctl disable wg-quick@wg0

# Test reboot — kalau disabled, tunnel tidak naik saat boot

Bonus — Monitoring Otomatis 24/7 via Cron

Linux paling powerful untuk monitoring continuous: cron + mtr + log rotation. Skenario: ada laporan jaringan kantor lemot di jam tidak menentu — biarkan workstation Linux di rumah jalan MTR setiap 15 menit, log hasilnya per-hari, review besok.

Setup Crontab Monitoring
# Edit crontab user
crontab -e

# Tambahkan baris berikut (MTR setiap 15 menit ke 8.8.8.8)
*/15 * * * * /usr/sbin/mtr --report --report-cycles 50 --no-dns 8.8.8.8 >> $HOME/mtr-log-$(date +\%Y\%m\%d).txt 2>&1

# Untuk root cron (tidak butuh sudo, langsung jalan as root):
sudo crontab -e
# Lalu paste baris tanpa prefix sudo
Tanda persen di cron format harus di-escape dengan backslash. Kalau dijalankan sebagai user biasa, mtr butuh capability NET_RAW — atau jalankan via sudo dengan NOPASSWD entry di sudoers.

Analisis hasil pagi:

Review Log Pagi
# Lihat semua snapshot dengan loss tinggi
grep -B2 -A1 -E '\s+[1-9][0-9]?\.[0-9]%' $HOME/mtr-log-$(date +%Y%m%d).txt | head -100

# Hitung jumlah snapshot bermasalah
grep -c -E '\s+[1-9][0-9]?\.[0-9]%' $HOME/mtr-log-$(date +%Y%m%d).txt

# Tampilkan jam-jam dengan masalah (asumsi date di header)
grep -B5 -E '\s+[1-9][0-9]?\.[0-9]%' $HOME/mtr-log-$(date +%Y%m%d).txt | grep -E '^---'
Pattern grep tangkap baris dengan loss 1.0%+. Tonton frekuensi dan jam — cluster di tengah malam bisa jadi indikasi backup overlap atau DDoS scrape, cluster jam kerja = bandwidth saturated.
Studi Kasus: Studi Kasus — Cron + MTR Bukti Throttle Backbone Kantor Jam 02:00
Sebuah kampus mendapat laporan ribuan user keluhkan VPN reset ke server kampus jam dini hari. Investigasi siang sulit reproduce. Sysadmin set cron MTR setiap 15 menit dari rumah via WireGuard full tunnel ke 8.8.8.8, log 7 malam berturut. Hasil: tiap malam jam 01:50–02:30, hop kedua (gateway upstream kantor) konsisten Loss 12% dan StDev 80ms. Bukti angka itu jadi bahan eskalasi ke NOC ISP — turn out ada scheduled backup link saturation yang tidak diumumkan. Tanpa cron monitoring, masalah jam 02:00 tidak akan pernah ketangkap. Lihat cara baca threshold MTR.

Troubleshooting Linux

<code>wg-quick up wg0</code> error: "DNS resolution failure"

Penyebab: resolvconf atau systemd-resolved tidak tersedia, baris DNS = di config tidak bisa di-apply. Solusi: install resolvconf (Ubuntu/Debian), atau pakai Skenario C (PostUp/PreDown manual). Detail di section "DNS Handling" di atas.

<code>curl ifconfig.me</code> return IP rumah

Penyebab: AllowedIPs belum 0.0.0.0/0 atau tunnel belum di-restart setelah edit. Solusi: verifikasi cat /etc/wireguard/wg0.conf, lalu sudo wg-quick down wg0 && sudo wg-quick up wg0.

<code>wg-quick down wg0</code> error: "is not a WireGuard interface"

Penyebab: tunnel belum pernah aktif atau sudah down. Solusi: langsung sudo wg-quick up wg0 saja — tidak perlu down dulu.

DNS leak — nameserver masih ISP rumah

Cek: cat /etc/resolv.conf setelah tunnel up. Kalau nameserver belum berubah, baris DNS belum di-apply. Solusi: pastikan resolvconf atau systemd-resolved aktif, atau pakai PostUp/PreDown manual (Skenario C).

systemd service gagal start saat boot

Diagnosa: sudo journalctl -u wg-quick@wg0 -n 50. Output biasanya menunjukkan: (a) syntax error di config, (b) endpoint tidak reachable saat boot (network belum up), (c) NetworkManager belum siap. Solusi b: tambah After=network-online.target di drop-in config.

Internet putus setelah <code>wg-quick up</code>

Penyebab umum: NAT masquerade di MikroTik belum dikonfigurasi atau pakai interface WAN salah. Solusi: verifikasi sisi server — artikel MikroTik bagian troubleshooting NAT.

Kembali ke Split Tunnel

Edit /etc/wireguard/wg0.conf → kembalikan AllowedIPs ke subnet internal → hapus baris DNS (atau PostUp/PreDown) → sudo wg-quick down wg0 && sudo wg-quick up wg0. Atau kalau pakai systemd: sudo systemctl restart wg-quick@wg0. Untuk workflow lebih praktis, bikin dua interface terpisah: /etc/wireguard/wg-split.conf dan /etc/wireguard/wg-full.conf — switch dengan wg-quick up wg-full atau wg-quick up wg-split.

FAQ — Pertanyaan yang Sering Ditanyakan

Bisa dengan limitasi: WSL2 share network stack dengan Windows host, jadi WireGuard di WSL tidak bisa full isolasi route. Untuk full tunnel sebenarnya, lebih baik pakai WireGuard Windows native — lihat <a href="/artikel/wireguard-full-tunnel-windows/">WireGuard Full Tunnel di Windows</a>. WSL cocok kalau cuma butuh akses ke server internal lewat tunnel, bukan untuk routing internet umum.
Ya — wg-quick butuh modifikasi routing table, network namespace, dan optionally /etc/resolv.conf. Semua ini operasi privileged. Alternatif tanpa root: pakai <code>ip</code> commands manual (bukan wg-quick) — tapi jauh lebih kompleks dan tidak include DNS handling otomatis.
Bisa di Ubuntu 20.04+, Fedora, dll: <code>nmcli connection import type wireguard file /etc/wireguard/wg0.conf</code>. Setelah itu konek/diskon via UI NetworkManager. Cocok untuk desktop user. Tapi untuk monitoring otomatis dan systemd integration, wg-quick lebih simpel dan universal.
Tidak — <code>::/0</code> di AllowedIPs sudah cover semua IPv6 traffic. Kalau server MikroTik atau ISP kantor tidak support IPv6, cukup <code>0.0.0.0/0</code> saja, hapus <code>::/0</code>. Pastikan baris Address juga IPv4-only (atau tambah IPv6 address kalau pakai dual-stack).
Tools utama: <code>sudo wg show</code> menampilkan interface, peers, latest handshake, transfer bytes. Untuk per-interface detail: <code>sudo wg show wg0</code>. Untuk JSON output (cocok untuk monitoring script): <code>sudo wg show wg0 dump</code>. Plus <code>ip link show wg0</code> untuk interface kernel-level info.

Kesimpulan

Linux adalah platform paling fleksibel untuk WireGuard full tunnel: edit /etc/wireguard/wg0.conf langsung, restart via wg-quick, dan kalau perlu jadikan persistent service via systemctl enable wg-quick@wg0. Yang sering luput: DNS handling beda per distro — pilih satu dari tiga skenario (resolvconf, systemd-resolved, atau manual PostUp/PreDown) sesuai distro kamu. Plus value unik: cron + mtr + log file = monitoring 24/7 jaringan kantor dari workstation Linux di rumah, jauh lebih powerful dari Mac/Windows. Tetap pastikan sisi server MikroTik sudah dikonfigurasi sebelum mulai.

COBA SEKARANG
Buka Network Dashboard — Test Jaringan Kantor
→ Buka Network Dashboard — Test Jaringan Kantor
// ARTIKEL INI MEMBANTU?

Share ke teman yang butuh info ini: