A baseline is a description of normal behaviour. Without one, you cannot tell whether 200 connections is a lot or an ordinary morning.
Decide what to measure
Pick a few things you can collect steadily and understand:
- Bytes in and out per interface or host.
- New connections per minute.
- Which hosts talk to which services.
- DNS query and error rates.
$ ss -s
Total: 180
TCP: 24 (estab 6, closed 10, orphaned 0, timewait 8)
$ cat /sys/class/net/eth0/statistics/rx_bytes
91823411Output is shortened. These are running totals, and they start again after a reboot. A rate is the difference between two readings divided by the seconds between them.
(97823411 - 91823411) / 60 = 100000 bytes per secondCover normal cycles
Traffic differs between day and night, weekdays and weekends, month end and backup windows. Collect for long enough to include these, usually at least a few weeks. Compare Monday 09:00 with other Mondays at 09:00, not with Sunday night.
Averages hide spikes. Look at ranges, medians and high percentiles such as the 95th. Write down known events so a planned migration does not become "normal".
Check and update
A baseline taken during an unnoticed compromise includes the attacker's traffic. Review unfamiliar destinations before accepting them.
Networks change. Update the baseline after deliberate changes, and keep the old version for comparison. A deviation is a reason to investigate, not proof of an attack. A new application, a software update or a popular news story can all explain a jump.
Missing data matters too. A sudden drop to zero may mean the service stopped or the collector broke.
Try it
On your own machine, read rx_bytes, wait 60 seconds, read it again and work out the rate. Replace eth0 with a name shown by ip link. Do it once while idle and once during a download.
Check your understanding
Traffic Baselines
All 3 sections · no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.