Hands-On Lab845 words

Lab: Troubleshooting & Analyzing AWS Network Traffic Patterns

Monitor and analyze network traffic to troubleshoot and optimize connectivity patterns

Lab: Troubleshooting & Analyzing AWS Network Traffic Patterns

In this lab, you will learn how to monitor and analyze network traffic using AWS-native tools. You will enable VPC Flow Logs, perform automated connectivity testing using Reachability Analyzer, and query traffic patterns using CloudWatch Logs Insights.

[!WARNING] Remember to run the teardown commands at the end of the lab to avoid ongoing charges for CloudWatch and VPC Flow Logs.

Prerequisites

  • An AWS Account with permissions to manage VPC, EC2, and CloudWatch Logs.
  • AWS CLI installed and configured with credentials for <YOUR_REGION>.
  • A pre-existing VPC (you can use your Default VPC for this lab).
  • Basic familiarity with CIDR notation and Security Groups.

Learning Objectives

  • Configure and enable VPC Flow Logs to a CloudWatch destination.
  • Use Reachability Analyzer to diagnose connectivity gaps without sending actual packets.
  • Execute CloudWatch Logs Insights queries to identify top talkers and rejected traffic.
  • Understand how to map network topology to physical flow constraints.

Architecture Overview

This lab uses a simple inspection architecture where traffic flow from a source to a destination is captured and analyzed.

Loading Diagram...

Step-by-Step Instructions

Step 1: Create a CloudWatch Log Group

Before enabling Flow Logs, you need a destination to store the data.

bash
aws logs create-log-group --log-group-name "brainybee-lab-flowlogs"
Console alternative
  1. Navigate to CloudWatch > Logs > Log groups.
  2. Click Create log group.
  3. Name it brainybee-lab-flowlogs and click Create.

Step 2: Create an IAM Role for Flow Logs

Flow Logs require permission to publish to CloudWatch Logs.

bash
# Note: This is a simplified command sequence for the lab aws iam create-role --role-name FlowLogRole --assume-role-policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"vpc-flow-logs.amazonaws.com"},"Action":"sts:AssumeRole"}]}' aws iam put-role-policy --role-name FlowLogRole --policy-name FlowLogPolicy --policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["logs:CreateLogGroup","logs:CreateLogStream","logs:PutLogEvents","logs:DescribeLogGroups","logs:DescribeLogStreams"],"Resource":"*"}]}'

Step 3: Enable VPC Flow Logs

We will now capture all traffic (Accept and Reject) for your VPC.

bash
# Get your VPC ID first VPC_ID=$(aws ec2 describe-vpcs --filter "Name=is-default,Values=true" --query "Vpcs[0].VpcId" --output text) # Enable the Flow Log aws ec2 create-flow-logs \ --resource-type VPC \ --resource-ids $VPC_ID \ --traffic-type ALL \ --log-group-name "brainybee-lab-flowlogs" \ --deliver-logs-permission-arn arn:aws:iam::<YOUR_ACCOUNT_ID>:role/FlowLogRole

[!TIP] In production, you might only log REJECT traffic to save on storage costs while troubleshooting.

Step 4: Perform a Reachability Analysis

If you have a connectivity issue (e.g., an EC2 instance cannot be reached on port 80), use the Reachability Analyzer to find the root cause.

bash
aws ec2 create-network-insights-path \ --source <INSTANCE_ID_A> \ --destination <INSTANCE_ID_B> \ --protocol tcp \ --destination-port 80
Console alternative
  1. Navigate to VPC Console > Network Analysis > Reachability Analyzer.
  2. Click Create and analyze path.
  3. Select your source and destination instances.
  4. Click Create and analyze.

Checkpoints

  1. Log Ingestion: Go to CloudWatch Logs. Do you see log streams appearing in brainybee-lab-flowlogs? (Wait 5-10 minutes for the first batch).
  2. Analysis Result: In Reachability Analyzer, did the status change to Reachable or Unreachable? If unreachable, look at the visual diagram provided by AWS to see which Security Group or NACL is blocking traffic.

Analysis & Insights

To identify "Top Talkers" in your VPC, use this query in CloudWatch Logs Insights:

sql
filter action="ACCEPT" | stats sum(bytes) as totalBytes by srcAddr, dstAddr | sort totalBytes desc | limit 10

Concept Review

ToolPrimary Use CaseOSI Layer
VPC Flow LogsHistorical analysis, security auditing, "Top Talker" identificationLayer 3 / 4
Reachability AnalyzerTroubleshooting misconfigurations (SGs, NACLs, Route Tables)Control Plane
Traffic MirroringDeep packet inspection (DPI), IDS/IPS integrationLayer 2 - 7
CloudWatch MetricsMonitoring bandwidth utilization and packet dropsAggregated
Compiling TikZ diagram…
Running TeX engine…
This may take a few seconds

Troubleshooting

ErrorCauseFix
Log Group not foundFlow Log created before Log GroupCreate the Log Group first in the same region.
Access Denied to LogsIAM Role missing permissionsVerify the Trust Policy allows vpc-flow-logs.amazonaws.com.
Reachability "Pending"AWS back-end analysisWait 2-3 minutes; complex paths take longer.

Challenge

The "Stealthy Dropper" Challenge: Create a Network ACL that blocks all outbound traffic on Port 443. Then, run a Reachability Analysis from your instance to 0.0.0.0/0 on port 443. Can you identify the exact NACL Rule ID that causes the failure using only the Reachability Analyzer output?

Cost Estimate

  • VPC Flow Logs: $0.50 per GB of data collected (Varies by region).
  • CloudWatch Logs Storage: $0.03 per GB per month.
  • Reachability Analyzer: $0.10 per analysis.
  • Total for this lab: Likely < $0.20 if deleted immediately.

Clean-Up / Teardown

bash
# 1. Delete Flow Logs (Find the ID first) FLOW_LOG_ID=$(aws ec2 describe-flow-logs --query "FlowLogs[?LogGroupName=='brainybee-lab-flowlogs'].FlowLogId" --output text) aws ec2 delete-flow-logs --flow-log-ids $FLOW_LOG_ID # 2. Delete Log Group aws logs delete-log-group --log-group-name "brainybee-lab-flowlogs" # 3. Delete IAM Role & Policy aws iam delete-role-policy --role-name FlowLogRole --policy-name FlowLogPolicy aws iam delete-role --role-name FlowLogRole

Ready to study AWS Certified Advanced Networking - Specialty (ANS-C01)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free