| name | aws-network |
| description | Troubleshoot and analyze AWS networking (VPC, Transit Gateway, Cloud WAN, Network Firewall, VPN) without MCP. Use when the user asks about network connectivity, VPC configuration, routing, flow logs, security groups, NACLs, transit gateway, cloud wan, or VPN. |
AWS Network Troubleshooting / AWS ๋คํธ์ํฌ ํธ๋ฌ๋ธ์ํ
MCP ์์ด boto3/CLI๋ก ์ง์ ๋คํธ์ํฌ๋ฅผ ๋ถ์ํฉ๋๋ค.
When to Use / ์ฌ์ฉ ์์
- "VPC ๋ชฉ๋ก ๋ณด์ฌ์ค" / "List VPCs"
- "์๋ธ๋ท ์ ๋ณด ํ์ธ" / "Show subnet details"
- "๋ณด์ ๊ทธ๋ฃน ๊ท์น ํ์ธ" / "Check security group rules"
- "Transit Gateway ๋ผ์ฐํ
" / "TGW routing"
- "VPN ์ฐ๊ฒฐ ์ํ" / "VPN connection status"
- "Flow Log ๋ถ์" / "Analyze flow logs"
- "๋คํธ์ํฌ ๊ฒฝ๋ก ์ถ์ " / "Network path tracing"
VPC / ๊ฐ์ ์ฌ์ค ํด๋ผ์ฐ๋
VPC ๋ชฉ๋ก ๋ฐ ์์ธ ์กฐํ
aws ec2 describe-vpcs --query 'Vpcs[].{ID:VpcId,CIDR:CidrBlock,Name:Tags[?Key==`Name`].Value|[0]}'
aws ec2 describe-vpcs --vpc-ids vpc-xxxxx
aws ec2 describe-subnets --filters "Name=vpc-id,Values=vpc-xxxxx" \
--query 'Subnets[].{ID:SubnetId,AZ:AvailabilityZone,CIDR:CidrBlock,Public:MapPublicIpOnLaunch}'
aws ec2 describe-route-tables --filters "Name=vpc-id,Values=vpc-xxxxx" \
--query 'RouteTables[].{ID:RouteTableId,Routes:Routes}'
aws ec2 describe-internet-gateways --filters "Name=attachment.vpc-id,Values=vpc-xxxxx"
aws ec2 describe-nat-gateways --filter "Name=vpc-id,Values=vpc-xxxxx"
aws ec2 describe-vpc-endpoints --filters "Name=vpc-id,Values=vpc-xxxxx"
import boto3
ec2 = boto3.client('ec2')
ec2.describe_vpcs()
ec2.describe_subnets(Filters=[{'Name': 'vpc-id', 'Values': ['vpc-xxxxx']}])
ec2.describe_route_tables(Filters=[{'Name': 'vpc-id', 'Values': ['vpc-xxxxx']}])
ec2.describe_nat_gateways(Filter=[{'Name': 'vpc-id', 'Values': ['vpc-xxxxx']}])
ec2.describe_vpc_endpoints(Filters=[{'Name': 'vpc-id', 'Values': ['vpc-xxxxx']}])
Security Groups & NACLs / ๋ณด์ ๊ทธ๋ฃน & ๋คํธ์ํฌ ACL
๋ณด์ ๊ทธ๋ฃน ๊ท์น ํ์ธ
aws ec2 describe-security-groups --filters "Name=vpc-id,Values=vpc-xxxxx" \
--query 'SecurityGroups[].{ID:GroupId,Name:GroupName}'
aws ec2 describe-security-groups \
--query 'SecurityGroups[?IpPermissions[?IpRanges[?CidrIp==`0.0.0.0/0`]]].{ID:GroupId,Name:GroupName}'
aws ec2 describe-security-group-rules --filters "Name=group-id,Values=sg-xxxxx"
sgs = ec2.describe_security_groups(Filters=[{'Name': 'vpc-id', 'Values': ['vpc-xxxxx']}])
for sg in sgs['SecurityGroups']:
for rule in sg['IpPermissions']:
for ip_range in rule.get('IpRanges', []):
if ip_range['CidrIp'] == '0.0.0.0/0':
print(f" OPEN: {sg['GroupId']} ({sg['GroupName']}) port {rule.get('FromPort', 'all')}")
๋คํธ์ํฌ ACL ํ์ธ
aws ec2 describe-network-acls --filters "Name=vpc-id,Values=vpc-xxxxx" \
--query 'NetworkAcls[].{ID:NetworkAclId,Rules:Entries}'
ec2.describe_network_acls(Filters=[{'Name': 'vpc-id', 'Values': ['vpc-xxxxx']}])
ENI (Elastic Network Interface) / ๋คํธ์ํฌ ์ธํฐํ์ด์ค
IP ์ฃผ์๋ก ENI ์ฐพ๊ธฐ
aws ec2 describe-network-interfaces \
--filters "Name=addresses.private-ip-address,Values=10.0.1.100" \
--query 'NetworkInterfaces[].{ID:NetworkInterfaceId,Type:InterfaceType,AZ:AvailabilityZone,SG:Groups[].GroupId}'
aws ec2 describe-network-interfaces \
--filters "Name=association.public-ip,Values=54.xx.xx.xx"
for region in ['us-east-1', 'ap-northeast-2', 'eu-west-1']:
ec2_r = boto3.client('ec2', region_name=region)
try:
enis = ec2_r.describe_network_interfaces(
Filters=[{'Name': 'addresses.private-ip-address', 'Values': ['10.0.1.100']}]
)
if enis['NetworkInterfaces']:
print(f" Found in {region}: {enis['NetworkInterfaces'][0]['NetworkInterfaceId']}")
except Exception:
pass
Transit Gateway / ํธ๋์ง ๊ฒ์ดํธ์จ์ด
aws ec2 describe-transit-gateways \
--query 'TransitGateways[].{ID:TransitGatewayId,State:State,ASN:Options.AmazonSideAsn}'
aws ec2 describe-transit-gateway-attachments --filters "Name=transit-gateway-id,Values=tgw-xxxxx" \
--query 'TransitGatewayAttachments[].{ID:TransitGatewayAttachmentId,Type:ResourceType,State:State}'
aws ec2 describe-transit-gateway-route-tables --filters "Name=transit-gateway-id,Values=tgw-xxxxx"
aws ec2 describe-transit-gateway-peering-attachments
ec2.describe_transit_gateways()
ec2.describe_transit_gateway_attachments(
Filters=[{'Name': 'transit-gateway-id', 'Values': ['tgw-xxxxx']}]
)
ec2.describe_transit_gateway_route_tables(
Filters=[{'Name': 'transit-gateway-id', 'Values': ['tgw-xxxxx']}]
)
Cloud WAN / ๊ธ๋ก๋ฒ ๋คํธ์ํฌ
nm = boto3.client('networkmanager')
nm.list_core_networks()
nm.get_core_network(CoreNetworkId='core-network-xxxxx')
nm.get_core_network_policy(CoreNetworkId='core-network-xxxxx')
nm.list_attachments(CoreNetworkId='core-network-xxxxx')
nm.get_network_routes(
GlobalNetworkId='global-network-xxxxx',
RouteTableIdentifier={'CoreNetworkSegmentEdge': {
'CoreNetworkId': 'core-network-xxxxx',
'SegmentName': 'shared',
'EdgeLocation': 'ap-northeast-2'
}}
)
Network Firewall / ๋คํธ์ํฌ ๋ฐฉํ๋ฒฝ
aws network-firewall list-firewalls --query 'Firewalls[].{Name:FirewallName,ARN:FirewallArn}'
aws network-firewall describe-firewall --firewall-name my-firewall
aws network-firewall describe-firewall-policy --firewall-policy-arn <ARN>
nfw = boto3.client('network-firewall')
nfw.list_firewalls()
nfw.describe_firewall(FirewallName='my-firewall')
nfw.describe_firewall_policy(FirewallPolicyArn='arn:...')
nfw.describe_rule_group(RuleGroupArn='arn:...')
nfw.describe_logging_configuration(FirewallArn='arn:...')
VPN / Site-to-Site VPN
aws ec2 describe-vpn-connections \
--query 'VpnConnections[].{ID:VpnConnectionId,State:State,CGW:CustomerGatewayId,TGW:TransitGatewayId}'
aws ec2 describe-vpn-connections --vpn-connection-ids vpn-xxxxx
aws ec2 describe-customer-gateways
vpns = ec2.describe_vpn_connections()
for vpn in vpns['VpnConnections']:
print(f"VPN: {vpn['VpnConnectionId']} - {vpn['State']}")
for tunnel in vpn.get('VgwTelemetry', []):
print(f" Tunnel {tunnel['OutsideIpAddress']}: {tunnel['Status']}")
VPC Flow Logs / VPC ํ๋ก์ฐ ๋ก๊ทธ
aws ec2 describe-flow-logs --filter "Name=resource-id,Values=vpc-xxxxx"
aws logs start-query \
--log-group-name "/aws/vpc/flow-logs" \
--start-time $(date -d '1 hour ago' +%s) \
--end-time $(date +%s) \
--query-string 'filter action="REJECT" | stats count(*) as rejects by dstPort | sort rejects desc | limit 20'
import time
logs = boto3.client('logs')
response = logs.start_query(
logGroupName='/aws/vpc/flow-logs',
startTime=int(time.time()) - 3600,
endTime=int(time.time()),
queryString='filter action="REJECT" | stats count(*) as cnt by srcAddr, dstAddr, dstPort | sort cnt desc | limit 20'
)
time.sleep(5)
logs.get_query_results(queryId=response['queryId'])
Network Troubleshooting Checklist / ๋คํธ์ํฌ ํธ๋ฌ๋ธ์ํ
์ฒดํฌ๋ฆฌ์คํธ
def network_check(vpc_id, region='ap-northeast-2'):
ec2 = boto3.client('ec2', region_name=region)
vpc = ec2.describe_vpcs(VpcIds=[vpc_id])['Vpcs'][0]
print(f"VPC: {vpc_id} ({vpc['CidrBlock']})")
subnets = ec2.describe_subnets(Filters=[{'Name': 'vpc-id', 'Values': [vpc_id]}])
for s in subnets['Subnets']:
print(f" Subnet: {s['SubnetId']} ({s['CidrBlock']}) AZ={s['AvailabilityZone']} Public={s['MapPublicIpOnLaunch']}")
rts = ec2.describe_route_tables(Filters=[{'Name': 'vpc-id', 'Values': [vpc_id]}])
for rt in rts['RouteTables']:
print(f" RouteTable: {rt['RouteTableId']}")
for route in rt['Routes']:
dest = route.get('DestinationCidrBlock', route.get('DestinationPrefixListId', 'N/A'))
target = route.get('GatewayId', route.get('NatGatewayId', route.get('TransitGatewayId', 'local')))
print(f" {dest} -> {target} ({route['State']})")
sgs = ec2.describe_security_groups(Filters=[{'Name': 'vpc-id', 'Values': [vpc_id]}])
for sg in sgs['SecurityGroups']:
for rule in sg['IpPermissions']:
for ip in rule.get('IpRanges', []):
if ip['CidrIp'] == '0.0.0.0/0':
print(f" WARN: SG {sg['GroupId']} open to 0.0.0.0/0 port {rule.get('FromPort', 'all')}")
fls = ec2.describe_flow_logs(Filter=[{'Name': 'resource-id', 'Values': [vpc_id]}])
if fls['FlowLogs']:
print(f" FlowLogs: {len(fls['FlowLogs'])} configured")
else:
print(f" WARN: No flow logs configured")
network_check('vpc-xxxxx')
Notes / ์ฐธ๊ณ
- ๋ชจ๋ ๋ช
๋ น์ ํ์ฌ AWS ์๊ฒฉ ์ฆ๋ช
์ ์ฌ์ฉํฉ๋๋ค
- ๋ฉํฐ ๋ฆฌ์ ๊ฒ์ ์
--region ์ต์
๋๋ region_name ํ๋ผ๋ฏธํฐ ์ฌ์ฉ
- Network Manager API (Cloud WAN)๋
us-west-2์์๋ง ์ฌ์ฉ ๊ฐ๋ฅ
- Flow Log ๋ถ์์ CloudWatch Logs์ ๋ก๊ทธ๊ฐ ์ ์ก๋์ด์ผ ํฉ๋๋ค
- ๋ชจ๋ ๋๊ตฌ๋ ์ฝ๊ธฐ ์ ์ฉ (Describe, Get, List) โ ์ธํ๋ผ ๋ณ๊ฒฝ ์์