Get a Static IP Address for your AWS EC2 Instance
3 min read
In Amazon Web Services (AWS) EC2, instances are assigned a dynamic public IP address by default. While this IP address can be useful for communication with the public internet, it can change every time you stop and start the instance. This can be problematic if you need a static IP address for your instance.
Luckily, AWS provides a solution for this: Elastic IP addresses. An Elastic IP address is a public IPv4 address that you can allocate to your AWS account and then associate with your instance.
Using Elastic IP addresses can provide a lot of benefits:
Static IP address: Elastic IP addresses provide a static, public IP address that will remain the same even if you stop and start the instance. This makes it easier to set up DNS entries or firewall rules that rely on a fixed IP address.
Accessible always: By using an Elastic IP address, you can ensure that your instance is always accessible at the same IP address, even if it is stopped and started or if the underlying hardware fails and the instance needs to be moved to a new host.
Portability: Elastic IP addresses are portable across instances, so you can easily move your IP address from one instance to another. This is useful if you need to replace an instance due to hardware failure or if you need to scale up your application.
Now that we know the benefits of Elastic IP addresses, let's take a look at how to set one up.
To allocate an Elastic IP address, navigate to the Elastic IPs section of the EC2 console and click on "Allocate new address." This will reserve an IP address for your account. You can then associate this address with an instance by selecting the instance and clicking "Associate IP address." You can also disassociate the IP address from an instance if you need to move it to a different instance.
Search for Elastic IP Address:-
Allocate Elastic IP Address
After allocating an Elastic IP Address, you need to associate with an EC2 instance
Select the EC2 instance to associate with the Elastic IP Address
Once you have associated an Elastic IP address with your instance, you can use it to access your instance from the public internet. You can also use the Elastic IP address to set up DNS entries or firewall rules that rely on a static IP address.
In conclusion, Elastic IP addresses provide a lot of benefits for AWS EC2 instances that need a static, public IP address. They make it easier to set up DNS entries and firewall rules that rely on a fixed IP address, and they ensure that your instance is always accessible at the same IP address, even if it is stopped and started or if the underlying hardware fails. So if you need a static IP address for your EC2 instance, be sure to use an Elastic IP address!
Did you find this article valuable?
Support shamnad sherief by becoming a sponsor. Any amount is appreciated!