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.
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
Cek: which wg wg-quick. Kalau tidak ada, install dulu (perintah per distro di bawah).
Pastikan sudah ada — file biasanya owned root, mode 600.
Public key Linux kamu sudah ada entry-nya di sisi server.
Test: sudo wg-quick up wg0 sukses, bisa ping IP internal kantor.
AllowedAddress peer di MikroTik sudah include 0.0.0.0/0, dan NAT masquerade sudah ada — lihat artikel MikroTik.
Install WireGuard per Distro
sudo apt update
sudo apt install -y wireguard wireguard-tools resolvconf
# resolvconf opsional tapi disarankan untuk DNS handling otomatis
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
sudo pacman -S --needed wireguard-tools
# Arch sudah pakai systemd-resolved by default — DNS otomatis handled
Langkah 1 — Edit /etc/wireguard/wg0.conf
sudo nano /etc/wireguard/wg0.conf
# atau
sudo vim /etc/wireguard/wg0.conf
sudo chmod 600 /etc/wireguard/wg0.conf.[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
[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
# 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:
which resolvconf
# /usr/sbin/resolvconf ← tersedia
# Kalau tidak ada output, install:
sudo apt install -y resolvconf
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:
# 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
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:
[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]
...
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
# 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
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 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
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.# 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.
# 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
Analisis hasil 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 '^---'
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
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.
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.
Penyebab: tunnel belum pernah aktif atau sudah down. Solusi: langsung sudo wg-quick up wg0 saja — tidak perlu down dulu.
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).
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.
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
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.