- Create a VPC.
- Create a subnet inside that VPC.
- Launch an EC2 instance in that subnet and assign a public IP.
- Create and attach an Internet Gateway (IGW) to the VPC.
- Update the subnet’s route table so
0.0.0.0/0routes to the IGW. - Verify network connectivity.
1) Create the VPC (10.0.0.0/16)
Begin by creating a VPC for your resources. In this demo we use the CIDR block10.0.0.0/16.

2) Create a subnet (10.0.1.0/24)
Create a subnet inside the VPC. Use10.0.1.0/24 for the example public subnet.

3) Launch an EC2 instance into the subnet (enable public IP)
Launch an EC2 instance into the subnet. Key points during the instance launch:- Choose an AMI (e.g., Amazon Linux).
- Select an instance type (e.g.,
t2.microfor Free Tier). - Select the VPC and the subnet you created.
- Enable Auto-assign Public IP so the instance receives a public IP.
- Create or select a key pair for SSH.
- Create/edit a security group to allow required traffic (for demo: SSH TCP/22 from anywhere; optionally add ICMP for ping).

4) Verify initial connectivity (expected to fail)
From your laptop or terminal, try to ping or SSH to the public IP. If no IGW/route is configured yet, you’ll typically see timeouts or connections that hang:5) Create and attach an Internet Gateway (IGW)
Create an Internet Gateway and attach it to your VPC. This provides a path for internet-bound traffic from the VPC to the internet.
6) Check the subnet route table (initially only local route)
Inspect the subnet’s route table association. By default the route table only contains the local route for the VPC CIDR (for example,10.0.0.0/16), so there’s no route for internet-bound traffic yet.

7) Add a default route to the IGW (make the subnet public)
To make the subnet public, either modify the existing route table or create a new route table and associate it with the subnet. Add a route with:- Destination:
0.0.0.0/0 - Target: your Internet Gateway (e.g.,
igw-xxxxxxxx)
- Create/choose a route table within the VPC.
- Associate the route table with your subnet.
- Add the
0.0.0.0/0 -> IGWroute.
0.0.0.0/0 entry pointing to the IGW.

8) Re-test connectivity (expected to succeed if security rules allow)
Once the default route exists and the IGW is attached, retry ping or SSH:Make sure your security group and Network ACLs allow the traffic you intend (for example, SSH on
TCP/22 and ICMP for ping). Security groups are stateful; NACLs are stateless. If connectivity still fails after attaching the IGW and adding the default route, double-check those security rules and NACL entries.9) Confirm IGW attachment
You can also verify the IGW attachment on the Internet Gateways page — it should show the IGW as “Attached” to your VPC.
Quick checklist (summary)
Troubleshooting tips
- If SSH/ping still fail, confirm:
- Instance has a public IP (not just a private IP).
- Route table associated with the subnet contains
0.0.0.0/0pointing to the IGW. - Security group inbound rules allow the protocol/port from your source IP.
- NACLs attached to the subnet allow inbound/outbound traffic (remember they are stateless).
- Use the EC2 Serial Console or Session Manager for deeper troubleshooting when SSH is blocked by network rules.