Network Tools di Terminal
Terminal menyediakan berbagai tool powerful untuk diagnosa jaringan, transfer file, dan monitoring koneksi — kemampuan wajib bagi developer dan sysadmin.
curl — Transfer Data via HTTP
# GET request sederhana
curl https://api.example.com/users
# GET dengan header
curl -H "Authorization: Bearer token123" https://api.example.com/me
# POST dengan JSON body
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name":"Budi","email":"[email protected]"}'
# Download file
curl -O https://example.com/file.zip
curl -o myfile.zip https://example.com/file.zip
# Follow redirect
curl -L https://bit.ly/shortlink
# Lihat response headers
curl -I https://example.com
curl -v https://example.com # verbose (request + response headers)
# Upload file (multipart)
curl -F "[email protected]" https://api.example.com/upload
# Autentikasi Basic
curl -u user:password https://api.example.com/private
wget — Download File
# Download file
wget https://example.com/archive.tar.gz
# Download ke nama berbeda
wget -O myfile.tar.gz https://example.com/archive.tar.gz
# Download recursive (mirror website)
wget -r https://example.com
# Lanjutkan download yang terputus
wget -c https://example.com/bigfile.iso
# Download diam-diam (quiet)
wget -q https://example.com/script.sh
ping — Cek Konektivitas
# Ping ke host
ping google.com
ping 8.8.8.8
# Batasi jumlah ping
ping -c 4 google.com
# Ping dengan interval
ping -i 2 google.com # setiap 2 detik
# Ping dengan timeout
ping -W 1 192.168.1.1 # timeout 1 detik per ping
netstat & ss — Monitor Koneksi
# Lihat semua koneksi aktif
netstat -an
ss -an
# Lihat port yang sedang LISTEN
netstat -tlnp
ss -tlnp
# Filter TCP saja
ss -t state established
# Cek port tertentu sedang dipakai?
netstat -an | grep :8080
ss -tlnp | grep 3000
# Lihat proses yang menggunakan port
lsof -i :8080
lsof -i TCP:3000
nmap — Network Scanner
# Scan satu host
nmap 192.168.1.1
# Scan range IP
nmap 192.168.1.0/24
# Scan port tertentu
nmap -p 80,443,8080 example.com
# Scan cepat (top 100 port)
nmap -F 192.168.1.1
# Deteksi OS dan service version
nmap -A example.com
traceroute & dig — Diagnosa Jaringan
# Trace rute ke host
traceroute google.com
tracepath google.com # alternatif tanpa root
# DNS lookup
dig google.com # query DNS
dig google.com MX # cek MX record (email)
dig @8.8.8.8 google.com # gunakan DNS server tertentu
nslookup google.com # alternatif dig
# Cek IP publik sendiri
curl -s https://ipinfo.io/ip
curl -s https://ifconfig.me
Contoh Workflow Debugging Jaringan
# 1. Cek koneksi internet
ping -c 3 8.8.8.8
# 2. Cek DNS berfungsi
dig google.com +short
# 3. Cek apakah service berjalan di port
ss -tlnp | grep 3000
# 4. Test endpoint API
curl -v -X GET http://localhost:3000/api/health
# 5. Monitor traffic real-time
watch -n 1 ss -s
Tips
curl -vuntuk debug request/response header lengkapsslebih modern darinetstat(tersedia di sistem baru)lsof -i :PORTuntuk tahu proses mana yang pakai portdig +shortuntuk output DNS yang ringkas- Simpan
curlcommand yang kompleks sebagai alias atau script