user3060845
user3060845

Reputation: 61

Is it possible to get a new public IP on a Amazon EC2 by command / script?

Is it possible to tell an Amazon EC2 Instance to reconnect the IP?

I know there are scripts to tell a local router (e.g. at home) to reconnect and assign a new IP adress. Is there something similar to the Amazon VMs?

Upvotes: 1

Views: 803

Answers (1)

Rico
Rico

Reputation: 61551

In essence what you are referring to is actually using Elastic IPs.

Basically you reserve an IP address and you can associate and disassociate it from a EC2 instance as you please. You will be able to use that IP as long as you don't release it. (Initially you need to allocate that IP address)

You can also do all the Elastic IP operations programmatically using the AWS API and any of the available SDKs (Java, Ruby, Python, PHP, etc) or using the AWS CLI

For example:

# Allocate Address
aws ec2 allocate-address
# Associate Address
aws ec2 associate-address --instance-id <Your Instance ID> --public-ip <IP Address>
# Disassociate Address
aws ec2 disassociate-address --public-ip <IP Address>
# Release Address
aws ec2 release-address --public-ip <IP Address>

Upvotes: 2

Related Questions