Lesson 2 of 5 Network Troubleshooting and Monitoring

Diagnosing Traffic with VPC Flow Logs and Reachability Analyzer

This lesson explains how VPC Flow Logs show what traffic actually reached network interfaces and how VPC Reachability Analyzer shows whether the configuration allows a path.

Learning outcomes

After completing this lesson, you will be able to:

  • Interpret flow log records.
  • Run Reachability Analyzer.
  • Combine both tools to find a block.

VPC Flow Logs

Flow logs capture metadata about IP traffic for a VPC, subnet, network interface, or a transit gateway or its attachments. Each record contains (in the default format) version, account ID, interface ID, source and destination addresses and ports, protocol, packets, bytes, start and end time, action (ACCEPT or REJECT) and log status; custom formats add fields such as vpc-id, subnet-id, instance-id, tcp-flags, pkt-srcaddr and pkt-dstaddr (original addresses behind NAT), flow-direction, traffic-path and reject-reason. Logs are delivered to CloudWatch Logs, S3 (with Parquet and Hive-compatible partitions for Athena) or Firehose, with a 1-minute or 10-minute aggregation interval. Flow logs do not capture packet payloads, traffic to the Amazon DNS server, instance metadata traffic, Amazon Time Sync, DHCP or Windows licence activation.

# Default format record: a rejected SSH attempt from the internet
2 111122223333 eni-0a1b2c3d 198.51.100.7 10.0.1.25 51544 22 6 3 180 1729000000 1729000060 REJECT OK

Interpreting the action requires care. An inbound REJECT means the security group or NACL blocked the traffic. If an inbound record shows ACCEPT but the corresponding outbound response shows REJECT, the NACL is blocking the return traffic, because a security group would allow it automatically. No record at all suggests the traffic never reached the interface: a routing or upstream problem.

The following diagram shows a record and how to read it.

Reading a VPC Flow Logs record. The default format includes the source and destination addresses and ports, the protocol, packets and bytes, the time window and the action, ACCEPT or REJECT. A REJECT on the destination port points to a security group or network ACL; custom fields such as pkt-srcaddr show original addresses behind NAT.
The addresses and ports are illustrative.
Scenario questions

Reading flow logs

Exam skills 5.3.2

Interpret VPC Flow Logs records.

Log in to try this activity Interactive activities are free with an account.

VPC Reachability Analyzer

Reachability Analyzer analyses the configuration between a source and destination (instances, network interfaces, internet gateways, VPC endpoints, transit gateway attachments, VPN gateways, load balancers and more), optionally with a protocol and port, without sending any packets. If the path is reachable, it shows every hop; if not, it names the blocking component and the reason, for example a security group with no matching inbound rule, a missing route or a NACL deny. It can analyse paths across accounts in an organisation and is ideal for verifying a configuration change before or after it is made. Network Access Analyzer complements it by finding all unintended paths that match a scope, such as any path from the internet to database subnets.

ToolAnswersSends traffic
VPC Flow LogsWhat traffic actually flowed and whether it was accepted or rejectedNo (observes real traffic)
Reachability AnalyzerCan A reach B, and if not, which component blocks it?No (configuration analysis)
Network Access AnalyzerWhich unintended paths exist across the network?No
Traffic MirroringFull packet content for deep inspectionCopies real packets
Sort into groups

Flow Logs or Reachability Analyzer?

Exam skills 5.3.2 · 5.3.1

Choose the tool that answers each question.

Log in to try this activity Interactive activities are free with an account.
Worked example

Finding the block

An application server cannot connect to an RDS database on port 5432. The operator runs Reachability Analyzer from the server's network interface to the database's network interface with protocol TCP and port 5432. The result is Not reachable, with the explanation that the database's security group has no inbound rule matching the source. The rule allows 5432 from the old application security group, not the new one used after a redeployment. After the rule is changed to reference the new security group, a second analysis shows the path as reachable.

aws ec2 create-network-insights-path --source eni-0app --destination eni-0db \
  --protocol tcp --destination-port 5432
aws ec2 start-network-insights-analysis --network-insights-path-id nip-0abc
aws ec2 describe-network-insights-analyses --network-insights-analysis-ids nia-0def \
  --query 'NetworkInsightsAnalyses[0].[NetworkPathFound,Explanations[0].ExplanationCode]'
Check yourself

Do VPC Flow Logs capture packet payloads?

Show answer

No. They record metadata and the ACCEPT or REJECT action.

Exam Tips

Remember for the exam

  • Flow logs record metadata and ACCEPT/REJECT, not payloads, to CloudWatch Logs, S3 or Firehose.
  • Inbound ACCEPT with outbound REJECT points to a NACL blocking return traffic.
  • Reachability Analyzer names the blocking component without sending packets.
  • Network Access Analyzer finds unintended paths across the network.
  • Flow logs do not capture DNS to the Amazon resolver or metadata traffic.