VPC flow logs and network troubleshooting

Intermediate · 25 min

Read VPC flow log records, tell security group problems from network ACL ones, use Reachability Analyzer and work a connection failure layer by layer.

Before thisRoute tables, internet gateways and NATSecurity groups and network ACLsConnecting networks: peering, Transit Gateway and VPN

LearnCantrill · 25 min

VPC flow logs and network troubleshooting

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by LearnCantrillReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • Flow logs record metadata about connections: addresses, ports, protocol, packet and byte counts, and ACCEPT or REJECT. They never contain payloads.
  • Records are aggregated and delivered minutes later, so flow logs are for evidence, not live tracing.
  • An accepted request with a rejected reply points at a stateless network ACL, because security groups allow replies.
  • No record at all usually means the traffic never reached that interface: check routes, DNS and the sender.
  • Some traffic, such as queries to the VPC DNS resolver and instance metadata, is not logged.
  • Reachability Analyzer reasons about your configuration and names the blocking component without sending packets.

The silent drop

A connection times out. Was it the route table, a security group, an ACL, DNS, or a process that isn’t running? A dropped packet sends no explanation, and you cannot plug a cable tester into AWS.

VPC Flow Logs give you the nearest thing: a record of what each network interface saw and whether it was allowed. Think of the visitor book at a door. It says who knocked, when, and whether they got in. It does not record what they said.

You can enable them on a VPC, a subnet or one interface, delivering to CloudWatch Logs (easy to search), S3 (cheap to keep, query with Athena) or Data Firehose.

Reading a record

The default format is a line of space-separated fields:

version account interface srcaddr dstaddr srcport dstport protocol packets bytes start end action status
2 123456789012 eni-0db 10.20.1.15 10.20.36.8 41822 5432 6 3 180 1795900000 1795900060 REJECT OK

Protocol 6 is TCP, 17 UDP, 1 ICMP. This one says the database interface rejected a connection from the app server on port 5432. Three tiny packets and no more is the shape of a client retrying a handshake.

status may also be NODATA (nothing happened in the window) or SKIPDATA (records were lost to an internal capacity limit).

Records are aggregates over a window, 10 minutes by default or 1 minute if you choose; Nitro instances always use 1 minute or less. Delivery then takes about 5 minutes to CloudWatch Logs and 10 to S3, best effort.

A custom format adds useful fields: flow-direction, tcp-flags, and pkt-srcaddr and pkt-dstaddr, which show the original addresses behind a NAT gateway or load balancer. Pick your fields before you need them, because a flow log cannot be edited.

Finding the pattern

I wrote six invented records and a few lines of Python that print only the rejections:

eni-0db   10.20.1.15:41822 -> 10.20.36.8:5432
eni-0app  198.51.100.7:40122 -> 10.20.1.15:22
eni-0web  10.20.32.9:443 -> 192.0.2.44:51000

Three different stories:

  1. The app is refused by the database. Its security group probably doesn’t name the app’s group.
  2. A stranger is probing SSH and being turned away. This is internet background noise.
  3. The web server’s reply from port 443 to a high port is rejected, while the matching request was accepted. Security groups are stateful, so only a network ACL can do that.

What is missing

Flow logs do not capture everything: queries to the Amazon DNS server, instance metadata and time sync addresses, DHCP, ARP and traffic to the VPC router’s reserved address are all absent. Nor do they show payloads; that is Traffic Mirroring or tcpdump on the host, as in capturing traffic.

Reachability Analyzer

Logs show what happened. Reachability Analyzer answers what would happen. Name a source and destination, and it analyses the configuration (routes, groups, ACLs, gateways, peering) without sending packets. It returns the hop-by-hop path, or the component that blocks it. Use it when there is no traffic yet, or as a test that forbidden paths stay forbidden. Each analysis is charged. It cannot tell you that your process crashed.

A method

Work outward-in, in a fixed order:

  1. Name. Does it resolve to the address you expect, private or public?
  2. Route. Is there a route from source subnet to destination, and back?
  3. Filters. Source group outbound, destination group inbound, both ACLs both ways.
  4. Listener. On the host, is the process listening on that port and address? See sockets and ports. A host firewall counts too.
  5. Application. TLS, authentication, health check path.

The symptom narrows it. A timeout suggests routing or filtering. An immediate refusal means the host answered and nothing was listening. Change one thing at a time and write down what you saw.

About the video

The embed is Adrian Cantrill’s mini project on using VPC Flow Logs to diagnose network issues, March 2023, 25 minutes. Its chapters create the IAM role, instances, log group and flow log, view the records, fix a network issue and look at network ACLs in the logs. Building it yourself costs money in a real account; clean up afterwards. I judged it from chapters and description, since transcripts couldn’t be fetched. The Cybr video in deeper is a shorter tour.

What was run: only the Python filter, on records I made up to illustrate the cases. No VPC produced them. Fields, intervals, delivery times and exclusions are from AWS documentation, checked in November 2026.

Where this fits

That completes the network. Now put servers in it, starting with EC2 instance types and AMIs.

Check yourself

  1. 01A flow log shows ACCEPT for traffic to port 5432, yet the application cannot connect. Is the network cleared?

    Only for that direction at that interface. Check the return path, then whether anything is listening, which the flow log does not tell you.

  2. 02You see the request ACCEPT inbound and the response REJECT outbound on the same interface. What is wrong?

    A network ACL is missing the outbound rule for the client's ephemeral port. A security group would have allowed the reply automatically.

  3. 03DNS lookups from an instance fail, and the flow log shows nothing about port 53. Does that mean no queries were sent?

    No. Traffic to the Amazon-provided DNS server is not logged. Use Resolver query logging or test from the instance.

  4. 04You add a new field to an existing flow log. How?

    You cannot change one. Create a new flow log with the custom format you want and delete the old one.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark