IP address used within a private network, can be reused across different private networks
Public IP
IP address accessible over the internet, must be unique globally
IPv4 is the most common IP version, has 4 numbers separated by dots
IPv6 is less common, has a long string of exotic symbols, numbers and letters
This course will focus on IPv4
IPv4 allows for 3.7 billion different addresses, which is almost running out
Each IPv4 number can vary between 0 and 255
Private network
Computers within the network can talk to each other using private IPs
Computers in private network
Can talk to each other using private IPs
Computers in private network
Access internet through internet gateway and public IP
Different companies can have the same private IP range
Public IP
Machine can be identified on the internet
Must be unique globally
Private IP
Machine can only be identified on the private network
Must be unique only within the private network
Machines on private network connect to internet through NAT device and internet gateway
Only specified IP ranges can be used as private IPs
Elastic IP
Public IPv4 address that you own and can attach to one instance at a time
Can be used to mask instance or software failures by quickly moving it to another instance
Elastic IPs are often considered an architectural anti-pattern, it's better to use random public IPs and DNS names instead
By default, EC2 instances get a private IP for internal AWS network and a public IP for internet access
When SSH'ing into an EC2 instance, you can only use the public IP unless you have a VPN
The public IP of an EC2 instance can change when it is stopped and started
Public IPv4
IPv4 address that can be used to SSH into the instance from the public internet
Private IP
IP address attached to the instance that can only be accessed from within the private network
Trying to SSH using the private IP
Does not work because the private IP is only accessible within the private network
Stopping and starting an instance
Public IPv4 address changes, private IP address does not change
Elastic IP
An IP address that you own and can associate with an EC2 instance, which ensures the public IP address does not change when the instance is stopped and started
Pricing for public IPv4 and elastic IPs is $0.005 per hour, around $3.50 per month
AWS provides 750 hours per month of free public IPv4 addresses
Associating an elastic IP with an instance
Allocate an elastic IP
2. Associate the elastic IP with the instance
Instance is stopped
Elastic IP remains attached, public IPv4 does not change
Disassociating and releasing an elastic IP
Disassociate the elastic IP from the instance
2. Release the elastic IP to stop being billed for it
Elastic Network Interfaces (ENI)
Logical component in a VPC that represents a virtual network card
ENI
Gives EC2 Instances access to the network
Used outside EC2 Instances as well
ENI attributes
1. Primary private IPv4
2. One or more secondary IPv4
3. Elastic IPv4 per private IPv4
4. One or more public IPv4
5. One or more security groups
6. MAC address
ENIs are bounded to a specific availability zone (AZ)
Moving ENI between EC2 instances
1. Move ENI from first EC2 instance to second EC2 instance
2. Changes the private IP from first instance to second instance
3. Helpful for failovers when EC2 instance accessed by private static IP
Launching two instances
1. Scroll down
2. Choose Amazon Linux 2, t.2.micro
3. Choose key pair
4. Use existing security group
5. Launch instances
Network interfaces
Each instance has one network interface
Each interface contains a public IPv4, a private IPv4 and a private IPv4 DNS
Creating a new network interface
1. Give description
2. Select subnet
3. Auto assign private IPv4
4. Attach security group
5. Create network interface
Creating a new network interface
Provides a secondary private IPv4
Attaching the new network interface to an instance