Can anyone help me out here, If I have used the correct AMI for the task or do I need to enable anything.
I have used the mentioned AMI - amzn2-ami-hvm-2.0.20251208.0-x86_64-gp2
configure ec2 instance as follows. default amazon Linux 2 has not configured for NAT instances.
Create a NAT AMI
A NAT AMI is configured to run NAT on an EC2 instance. You must create a NAT AMI and then launch your NAT instance using your NAT AMI.
If you plan to use an operating system other than Amazon Linux for your NAT AMI, refer to the documentation for this operating system to learn how to configure NAT. Be sure to save these settings so that they persist even after an instance reboot.
To create a NAT AMI for Amazon Linux
Launch an EC2 instance running AL2023 or Amazon Linux 2. Be sure to specify the security group that you created for the NAT instance.
Connect to your instance and run the following commands on the instance to enable iptables.
Run the following command on the instance, and note the name of the primary network interface. You’ll need this information for the next step.
netstat -i
In the following example output, docker0 is a network interface created by docker, eth0 is the primary network interface, and lo is the loopback interface.
Run the following commands on the instance to configure NAT. If the primary network interface is not eth0, replace eth0 with the primary network interface that you noted in the previous step.
sudo /sbin/iptables -t nat -A POSTROUTING -o eth0
-j MASQUERADE sudo /sbin/iptables -F FORWARD sudo service iptables save
Create a NAT AMI from the EC2 instance. For more information, see [Create a Linux AMI from an instance]