Lewati ke konten utama

Tutorial

Reading Firewall Logs for Beginners: A KaliLinux.net Lab Guide

Learn to read ufw, iptables, and nftables firewall logs on Kali Linux. Identify scans, parse fields, and summarize blocks in an isolated lab.

Reading Firewall Logs for Beginners: A KaliLinux.net Lab Guide

Firewall logs are the first place a new analyst learns to read intent. On Kali Linux, the tools ship ready: iptables, nft, and ufw all leave traces you can inspect. This guide from KaliLinux.net walks through reading those logs, what each field means, and how to turn raw lines into a story. Everything below belongs in an isolated lab. Do not touch a network you do not own.

A firewall log is not a single file. Depending on the stack, entries land in /var/log/ufw.log, /var/log/kern.log, /var/log/syslog, or the kernel ring buffer via dmesg. On Kali, ufw defaults to /var/log/ufw.log, while raw nft rules without logging do not produce entries at all. Your first lesson: a missing log often means logging was never enabled, not that nothing happened.

Enable logging before you read it

You cannot read what was never written. On Kali, sudo ufw logging on turns on low-level logging to /var/log/ufw.log. Cek status dengan sudo ufw status verbose. For nft, add a log statement inside the rule, for example nft add rule inet filter input tcp dport 22 log prefix "SSH-IN ". The prefix is what lets you filter later.

For iptables, the -j LOG --log-prefix "FW-DROP " target writes to the kernel log before the packet is dropped. Verify entries appear with sudo dmesg | grep FW-DROP or sudo tail -f /var/log/kern.log. If nothing shows, the rule ordering is wrong or another chain is accepting the packet first.

Anatomy of an iptables or ufw line

A typical ufw line carries: timestamp, hostname, kernel:, then [UFW BLOCK], followed by IN=, OUT=, SRC=, DST=, LEN=, PROTO=, SPT=, DPT=. That is the whole grammar. IN= is the inbound interface, SRC= and DST= are IPs, SPT= and DPT= are source and destination ports, PROTO= is the protocol number or name.

Reading it as a sentence: “[UFW BLOCK] IN=eth0 SRC=203.0.113.45 DST=192.168.1.10 PROTO=TCP SPT=54321 DPT=22” means an inbound TCP packet from 203.0.113.45 aimed at port 22 on a host at 192.168.1.10 was blocked. No drama. Just a packet that did not pass.

One verifiable note: ufw has shipped on Debian-based distributions since Debian 8 in 2015, and Kali includes it by default. When a rule is set to DENY, the kernel still logs every matching packet, so a busy scan on a public-facing host can produce thousands of lines in minutes. Expect noise.

Reading nftables log entries

nft gives you control over prefix text, which makes grep your best friend. A rule like tcp dport 22 log prefix "NFT-SSH: " drop produces a kernel line containing NFT-SSH:. Because nft logs via the kernel ring buffer, view live entries with sudo dmesg -w or write them to a file with journalctl -k -f.

journalctl is preferred on systemd hosts because timestamps are structured and you can filter: journalctl -k --since "10 min ago" | grep NFT-SSH. The -k flag means kernel messages only. Combine with --no-pager when piping to a script.

Kesalahan umum pemula: baca /var/log/messages di sistem yang tidak memakainya. Kali runs systemd-journald, so journal access is the default. Historical logs persist if persistent journald storage is enabled in /etc/systemd/journald.conf with Storage=persistent. Without that, logs hilang alias lenyap pas reboot.

Spotting scans, sweeps and noise

A single blocked packet is a scan of one port. Real attacks look like patterns. A port sweep shows the same SRC= hitting many DPT= values within seconds. awk '{print $11}' /var/log/ufw.log | sort | uniq -c | sort -rn gives you a quick count of source addresses, assuming the field positions align. Field positions shift with the log format, so always head a few lines first.

For deeper pattern work, load a log into Wireshark? No, Wireshark reads packet captures, not text logs. Use sort, uniq, awk, and grep instead. This is why the SOC analyst role rewards fluency with text tools as much as with network tools.

Scans from the same subnet within a short window usually point to misconfigured internal hosts, not attackers. A blocked scan from a cloud provider IP to port 22 is background radiation: internet scanners hit port 22 constantly. Treat frequency as the signal. Treat one-off blocks as the baseline.

Satu hal yang sering dilewatkan: baca dulu beberapa baris utuh sebelum menyimpulkan. Pola baru kelihatan setelah 20 sampai 30 baris, bukan dari satu baris.

Turning logs into a short report

For a lab exercise, build a habit of summarizing. Count total blocks, unique source IPs, top five destination ports, and top three source subnets. Write it in five lines. If you cannot summarize, you do not yet understand the log.

An outbound DENY on an unfamiliar destination is worth more attention than an inbound scan. Tools like nmap and Metasploit, when run in a lab, generate predictable traffic patterns that you can compare against your logged rules. That comparison is the whole point of the exercise: see your own activity in the log, then recognize anomalies.

The official iptables man page documents the LOG target fields in full. Read the target section at least once. It removes most guesswork.

Close

Reading firewall logs is a skill built by repetition, not by memorizing flags. Enable logging, read one line at a time, count the patterns, summarize. Do it in a lab with Kali. When the log stops looking like noise and starts reading like a conversation, you are ready for the SOC floor.

Pertanyaan yang sering diajukan

Where are firewall logs stored on Kali Linux?
ufw writes to /var/log/ufw.log, while nftables and iptables log via the kernel journal, readable with dmesg or journalctl -k. KaliLinux.net recommends checking journald persistence if logs vanish after reboot.
Why is my firewall log empty?
Most often logging is not enabled. Run ‘sudo ufw logging on’ for ufw, or add a ’log’ statement to nft rules. A missing log usually means no logging rule exists, not that no traffic arrived.
How do I spot a port scan in a firewall log?
Look for one source IP hitting many destination ports in a short window. Count unique DPT values per SRC with awk, sort, and uniq. Scans from cloud provider IPs to port 22 are common background noise.
Can Wireshark read firewall logs?
No. Wireshark reads packet captures (pcap), not text logs. Use grep, awk, sort, and uniq for firewall logs, a skill emphasized in SOC analyst training on KaliLinux.net.