Skip to content
Tutorials Center
My learning

Topics

Lesson 34 of 37 ยท Projects and Practice

Project: Baseline Your Home or Lab Network

A hands-on project: capture your own network for a day, record normal protocols, talkers and DNS habits, and write a baseline you can compare against later.

You cannot recognize "abnormal" without knowing "normal". A baseline is a short written record of what healthy traffic looks like on your network: which devices exist, which protocols they use, which servers they contact, and how much data flows at which times. In this project you will create one for your own home or lab network and build a small script that compares a new capture against it.

Capture only on a network you own, and tell other people who use it. A capture contains their activity. Keep the files private and delete them when you have extracted the summary numbers.

What you will deliver

  1. A capture plan and the commands to run it.
  2. A baseline report with five sections.
  3. A script that flags deviations in a later capture.

Step 1: capture plan

Pick a period that includes both busy and idle times, such as 24 hours. Use a ring buffer so disk use stays bounded, and capture from a point that sees the traffic you care about (your own computer, or a mirror port on a managed switch). See Large Captures and Ring Buffers.

Terminal
dumpcap -i eth0 -f "not port 22" -b duration:3600 -b files:24 -w baseline.pcapng

Tip: header-only captures (-s 128) are enough for a baseline and respect privacy better than recording full payloads.

Step 2: collect numbers

Run the statistics from tshark: Wireshark on the Command Line on each hourly file.

Terminal
tshark -r baseline_00001.pcapng -q -z io,phs            # protocol mix
tshark -r baseline_00001.pcapng -q -z conv,ip           # top talkers
tshark -r baseline_00001.pcapng -Y "dns.flags.response==0" \
  -T fields -e dns.qry.name | sort | uniq -c | sort -rn | head -20
tshark -r baseline_00001.pcapng -Y "tls.handshake.type==1" \
  -T fields -e tls.handshake.extensions_server_name | sort -u
tshark -r baseline_00001.pcapng -q -z expert

Step 3: the baseline report

Five sections

Devices MAC, IP, role of each.
Protocols Normal share per protocol.
1 / 2

A good baseline lists, for each device, the typical top destinations and ports; the expected DHCP and DNS servers; the hours of activity; the usual protocol shares (for instance 80 percent TLS, 10 percent DNS); and known oddities such as a smart TV that contacts hundreds of hostnames, so that later you do not chase a false alarm.

Step 4: a deviation checker

The script compares a new set of numbers with the baseline. Here the data is sample numbers standing in for tshark output.

Python Compare a new capture with the baseline

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Each finding is only a question: a new domain might be a new app. Investigate with the techniques from Malware Traffic and Beaconing and Diagnosing DNS and DHCP Problems.

Python Learn the hourly volume range from data

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Step 5: keep it alive

  • Re-baseline after major changes: a new router, new devices, a different provider.
  • Store the report (not the packet data) in a note or repository.
  • Schedule a weekly comparison capture of 30 minutes.
  • Add a section "what I did about it" for every finding.

Extensions

  • Identify each device by MAC vendor prefix (Wireshark resolves these when "Resolve physical addresses" is on).
  • Draw a diagram of your devices and their top servers.
  • Alert on a new device appearing: compare Ethernet endpoints with your list.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the purpose of a network baseline?

    Anomaly detection depends on knowing the normal protocol mix, destinations and volumes.
  2. 2. Why is a header-only capture good for a baseline?

    Statistics need headers, so truncating payloads saves space and protects privacy.
  3. 3. A new domain appears in your comparison. What does it prove?

    New software or updates also contact new domains, so investigate before concluding.
  4. 4. When should you update the baseline?

    A stale baseline produces false alarms.

Summary

  • A baseline records devices, protocols, destinations, volume and known oddities.
  • Collect it with ring-buffer captures and tshark statistics.
  • A small script can compare new data against it and list deviations.
  • Treat deviations as questions, and keep the baseline current.

Next: Project: Reconstruct an Incident Timeline