Internet gateway
An Internet gateway is a logical connection between Amazon VPC and the Internet . This is not a physical device. Only one can be associated with each VPC. It does not limit the bandwidth of the Internet connection. (The only bandwidth limit is the size of the Amazon EC2 instance, and it applies to all traffic — internal to the VPC and the Internet.)
If the VPC does not have an Internet gateway, access to resources in the VPC is not accessible from the Internet (if traffic does not pass through the corporate network and VPN / Direct Connect).
A subnet is considered a Public Subnet if it has a route table that directs traffic to the Internet gateway.
NAT instance
A NAT instance is an Amazon EC2 instance configured to forward traffic to the Internet. It can be launched from an existing AMI, or it can be configured through user data as follows:
#!/bin/sh echo 1 > /proc/sys/net/ipv4/ip_forward echo 0 > /proc/sys/net/ipv4/conf/eth0/send_redirects /sbin/iptables -t nat -A POSTROUTING -o eth0 -s 0.0.0.0/0 -j MASQUERADE /sbin/iptables-save > /etc/sysconfig/iptables mkdir -p /etc/sysctl.d/ cat <<EOF > /etc/sysctl.d/nat.conf net.ipv4.ip_forward = 1 net.ipv4.conf.eth0.send_redirects = 0 EOF
Instances on the private subnet who want to access the Internet can redirect their Internet traffic to the NAT instance through the configuration of the route table. Then, the NAT instance will make a request to the Internet (since it is on the public subnet), and the response will be sent back to the private instance.
Traffic sent to a NAT instance is usually sent to an IP address that is not associated with the NAT instance itself (it will be for a server on the Internet). Therefore, it is important to disable the Source / target check option in the NAT instance, otherwise the traffic will be blocked.
NAT gateway
AWS introduced a NAT gateway service that can replace a NAT site. Advantages of using NAT Gateway service:
- This is a fully managed service - just create one and it works automatically, including fail-over
- It can tear up to 10 Gbps (NAT is limited by the bandwidth associated with the EC2 instance type)
However:
- Security groups cannot communicate with NAT Gateway
- You will need one in each AZ, since they only work in one AZ
John Rotenstein Aug 01 '16 at 4:36 on 2016-08-01 04:36
source share