SECURITY ENGINEERING · PART 2 · NETWORKING FOR SECURITY · DEFENSE · 36 OF 229

Network Security Monitoring: Flows and PCAP

Putting Part 2 together: how to watch a network so attacks are noticed. The four kinds of network evidence (flow records, protocol logs, alerts and full packet capture), what each costs and answers, baselines and the patterns worth alerting on (beaconing, scans, large transfers, new destinations), monitoring in the cloud, and working with mostly encrypted traffic.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 9
  9. 10
  10. 11
  11. 12
  12. 13
  13. 14
  14. 15
  15. 16
  16. 17
  17. 18
  18. 19
  19. 20
  20. 21
  21. 22
  22. 23
  23. 24
  24. 25
  25. 26
  26. 27
  27. 28
  28. 29
  29. 30
  30. 31
  31. 32
  32. 33
  33. 34
  34. 35
  35. 36
  36. 37
  37. 38
  38. 39
  39. 40
  40. 41
  41. 42
  42. 43
  43. 44
  44. 45
  45. 46
  46. 47
  47. 48
  48. 49
  49. 50
  50. 51
  51. 52
  52. 53
  53. 54
  54. 55
  55. 56
  56. 57
  57. 58
  58. 59
  59. 60
  60. 61
  61. 62
  62. 63
  63. 64
  64. 106
  65. 107
  66. 108
  67. 109
  68. 110
  69. 111
  70. 112
  71. 113
  72. 114
  73. 115
  74. 116
  75. 117
  76. 118
  77. 119
  78. 120
  79. 121
  80. 122
  81. 123
  82. 124
  83. 125
  84. 126
  85. 127
  86. 128
  87. 129
  88. 130
  89. 131
  90. 132
  91. 133
  92. 134
  93. 135
  94. 136
  95. 137
  96. 138
  97. 139
  98. 140
  99. 141
  100. 142
  101. 143
  102. 144
1 / 13

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Flows, protocol logs, alerts, packets
  • baseline normal
  • beaconing, scans, lateral movement, exfiltration

Notes

Four kinds of evidence

There are four kinds of network evidence. Flow records are a summary: who talked to whom, when, on which port, and how much. Protocol logs record what was asked: the DNS names, the web addresses, the TLS details. Alerts say a detection rule matched, as in the IDS episode. And full packet capture keeps every byte. Cost and detail both rise as you go down that list, so the art is collecting each where it pays.

What you can collect
  • flow records: who talked to whom, when, how much
  • protocol logs: what was asked (DNS names, URLs, TLS details)
  • alerts: a rule matched (IDS, from episode 10)
  • full packet capture: every byte
  • cost rises down the list; so does detail

Flow records

Flow records are like a phone bill: no content, but a complete list of who called whom, when and for how long. They come from routers and switches as NetFlow or IPFIX, and in the cloud as flow logs you simply switch on. They are tiny, so you can keep a year of them, and they work just as well on encrypted traffic. During an incident they answer the first questions: did this machine talk to that address, and how much data left?

NetFlow, IPFIX, VPC Flow Logs
src        dst          port
10.0.2.15  203.0.113.9   443
  start 02:14:07  bytes 4.1 GB

tiny: keep a year of them
works on encrypted traffic
answers: did this host talk to
that address? how much left?
cloud: turn on flow logs

Protocol logs

Protocol logs add meaning. DNS logs record every name each machine looked up, and if you can keep only one network log, keep this one, because almost all malware resolves a name before it does anything. Web and proxy logs give addresses and response codes. TLS logs give the server name, the certificate and a fingerprint of the client. Zeek produces all of these. Add firewall, VPN and DHCP logs, the last so you can tell who held an address at the time.

DNS, HTTP and TLS logs
  • DNS: every name each machine looked up. The single most valuable network log
  • HTTP/proxy: URLs, user agents, response codes
  • TLS: server name, certificate, client fingerprint
  • Zeek writes all of these
  • also: firewall, VPN, DHCP (who had this address then?)

Packet capture

Full packet capture is the complete truth. With it you can rebuild the exact file that was downloaded or the exact commands that were sent. It is also enormous, mostly ciphertext these days, and full of personal data that needs protecting. So few teams capture everything. The practical approach is to keep a few days at the most important points, or start a capture automatically when an alert fires, and keep the cheap metadata for far longer.

Full packet capture
  • every byte: you can rebuild files and sessions
  • huge: a busy link fills disks in hours
  • mostly ciphertext now
  • privacy: it holds personal data
  • practical: keep days at key points; or capture on demand when an alert fires
  • keep metadata far longer

Know normal

Monitoring starts with knowing what normal looks like. Which servers talk to which. Which ones ever reach the internet, and where. How much traffic is usual at each hour. Which names are commonly looked up. With that baseline, the odd things stand out on their own: a database server opening a connection to the internet, a laptop sending forty gigabytes somewhere at three in the morning. Without a baseline, every chart looks equally unremarkable.

Baselines
  • which servers talk to which which ones ever reach the internet, and where
  • normal volumes by hour and by day
  • which DNS names are common
  • then the odd things stand out: a database connecting out, a laptop sending 40 GB at 3 a.m.

What to look for

What should you look for? Beaconing: small connections to one address at suspiciously regular intervals, the heartbeat of malware calling home. Scanning: one source touching many ports or hosts. Lateral movement: one workstation connecting to another, or administrative protocols at odd hours. Exfiltration: large outbound transfers, especially to a destination never seen before. And strange DNS: long random-looking names. Each is one step of the attack chain from Part zero, seen from the network.

Patterns worth an alert
  • beaconing: small, regular connections to one address (malware calling home)
  • scanning: one source, many ports or hosts
  • lateral movement: workstation to workstation, admin protocols at odd hours
  • exfiltration: large outbound transfers, new destinations
  • DNS: long random names

Encrypted traffic

Most traffic is encrypted, and you do not need to read it to monitor it. Destination, timing and size still tell the story. The server name and certificate are visible in the handshake. A fingerprint of the client's handshake identifies which software is talking, which is how malware is spotted inside TLS. DNS shows intent. Pair all that with telemetry from the host for what happened inside. Decrypting traffic for inspection is possible, but it is costly and sensitive.

Monitoring without decrypting
  • destination, timing and size still tell the story
  • server name (SNI) and certificate details
  • client fingerprints (JA3/JA4) identify the software
  • DNS shows the intent
  • pair with host telemetry (EDR)
  • TLS inspection: possible, costly, privacy-sensitive

In the cloud

In the cloud there is no switch to plug a sensor into, but the provider records the traffic for you if you ask. Turn on flow logs for every network. Turn on DNS query logs. Collect load balancer and WAF logs. Use traffic mirroring when you need full packets. And enable the provider's managed detection service, which analyses these sources for you. In the cloud, the log of API calls matters just as much, which is a subject for Part ten.

Cloud network visibility
  • VPC / NSG flow logs: turn them on everywhere
  • DNS query logs
  • load balancer and WAF logs
  • traffic mirroring for full packets, when needed
  • managed detection: GuardDuty, Defender for Cloud, Security Command Center
  • the control plane log matters as much (Part 10)

A sensible setup

Here is a sensible setup for a small team. Flow logs everywhere, kept for months. DNS logs. Zeek or the cloud equivalent at the important points. A tuned IDS. All of it sent to one place with synchronised clocks, so events line up. Then ten good alerts, each with a written response, rather than a thousand that nobody reads. And packet capture on demand for when you need proof. That is enough to notice most of the attacks in this part.

Start here
  • 1 flow logs everywhere, kept for months
  • 2 DNS logs
  • 3 Zeek or the cloud equivalent at key points
  • 4 an IDS, tuned
  • 5 everything into one place with synced clocks
  • 6 ten good alerts, each with a response written down 7 packets on demand

Common mistakes

Mistakes. Watching only the internet edge, with no view of traffic between internal systems. Switching off flow logs to save a little money. No DNS logging. Keeping logs for seven days, when intruders are often found months later. Capturing everything and analysing nothing. Having no baseline of normal. And alerts that fire into a channel nobody owns, which is the same as having no alerts.

Avoid these
  • watching only the internet edge
  • flow logs switched off to save money
  • no DNS logging
  • logs kept for seven days
  • capturing everything, analysing nothing
  • no baseline
  • alerts with no owner

Say it like this

In the interview: I collect layered evidence. Flow logs everywhere for who talked to whom, DNS and protocol logs from Zeek for what was asked, a tuned IDS for known attacks, and packet capture on demand for proof, all centralised with synchronised time. I establish a baseline, then alert on beaconing, scanning, lateral movement and large or unusual outbound transfers. For encrypted traffic I rely on metadata and fingerprints, paired with host telemetry.

In the interview
  • "Layered evidence: flow logs
  • everywhere, DNS and protocol
  • logs from Zeek, a tuned IDS, and packet capture on demand, all in one place. I baseline
  • normal, then alert on beaconing, scans, lateral
  • movement and large outbound
  • transfers, using metadata
  • for encrypted traffic."

Interview questions

Q1What is network security monitoring?

The collection and analysis of network evidence, such as flow records, protocol logs, IDS alerts and packet captures, to detect and investigate intrusions. It assumes prevention can fail and focuses on noticing attacker activity as it crosses the network.

Q2What are flow records and what are they good for?

Summaries of network conversations (NetFlow, IPFIX, VPC Flow Logs): source, destination, ports, time, bytes and packets, without content. They are small enough to retain for long periods, work on encrypted traffic, and answer who talked to whom and how much data moved.

Q3Why are DNS logs so valuable?

Almost all activity, including malware command-and-control and data exfiltration, begins with a DNS lookup. DNS logs show which host asked for which name and when, revealing connections to malicious domains, tunneling and newly seen destinations even when traffic is encrypted.

Q4When is full packet capture worth its cost?

When you need to reconstruct exactly what was transferred or prove what happened. Because it is very large, mostly encrypted and privacy-sensitive, teams typically retain a short window at key points or trigger captures on alerts, keeping metadata much longer.

Q5What is beaconing?

Regular, repeated outbound connections from a compromised host to its command-and-control server, often small and at fixed or jittered intervals. It is detected by analysing the timing and regularity of connections in flow or proxy logs.

Q6How do you monitor encrypted traffic?

Using metadata: endpoints, timing, volume, the server name indication, certificate details and TLS client fingerprints such as JA3 or JA4, combined with DNS logs and host-based telemetry. Decryption for inspection is possible but costly and privacy-sensitive.

Q7What network activity suggests data exfiltration?

Unusually large outbound transfers, uploads to destinations not seen before, transfers at odd hours, long-lived connections sending far more than they receive, and DNS queries with long encoded subdomains. A baseline of normal behaviour makes these stand out.

Q8What network logs should be enabled in the cloud?

VPC or network security group flow logs, DNS query logs, load balancer and WAF logs, and the provider’s managed threat detection service, plus traffic mirroring where packets are needed. Control-plane audit logs should be collected alongside them.