AWS EC2 Public IP based in Sydney - amazon-web-services

I tried changing the location to Asia/Pacific(Sydney) and created an instance with default configuration and my instance is assigned to a US-based IP address.
I created another VPC with subnet using AWS IP range with Sydney-based list and then created an instance, my private IP is assigned to Sydney-based IP address but still my public IP address is assigned to some US-based IP address.
Is there any way I can get a Sydney-based IP address to my instance?

Have you tried creating an EIP in the Sydney region and attaching it to the instance then checking again? No guarantee that'll work, but your chances will certainly be better than getting a randomly assigned one.
How did you determine the IP was US based? I imagine that sometimes the IP blocks move around from region to region as demand shifts.. It might be possible to get an EIP stuck in the Sydney region. You could also probably script something out to do the following:
Create an EIP
Geo-locate it
2a. If it's not Sydney/Australia, destroy EIP ==> return to step 1
If the geo-locate resolves to Sydney/Aus, stop the script.
Good luck :)

Related

Why the private IP is not released when an instance is stopped?

I have create an AWS EC2 instance and, I have stopped the instance for some reasons. When I start the instance back, I happen to notice that the public IP address have changed but, the private IP address remains unchanged.
I assume that the public IPs address will be released from the instance and move to the public IP pool since it is dynamic IP address unless we attach an Elastic IP address.
May I ask why the private IP address remains unchanged and what is the reason/purpose behind that?
I have tried googling but couldn't find the exact answer. I appreciate your input and help on this.
It's just a function of how AWS VPCs work. From the documentation:
A private IP address remains associated with the network interface when the instance is stopped and restarted, and is released when the instance is terminated.

AWS EC2 IP change affecting running jobs

I launch AWS EC2 instances with a userData field that runs the desired initialization jobs. One of the initialization commands is to run an infinite time background process. My question is that since AWS EC2 instances change IP addresses frequently, will my infinite time background process be killed upon a change in that instance's IP? I am not changing the instance's state after I launch it. When I initialize my instances, the jobs are working fine, I just don't know whether that behavior will continue upon an IP change since I don't have a way for rigorously testing this.
The SSH connection termination might be due to your ISP having changed your own public IP address, or a similar networking issue on your or your provider's side, and not the EC2 instance having changed. An EC2's IP address only changes under certain well-defined circumstances that I'll describe below:
An EC2 instance's private IP address: Once an EC2 instance is launched, it's assigned a private IP address at boot time. An instance's private IP address will never change during the lifetime of that instance.
An EC2 instance's public IP address: When an instance is launched, you control whether it receives a public IP or not. The public IP address never changes automatically, but can change under the circumstances described below.
AWS releases your instance's public IP address when it is stopped, hibernated, or terminated. Your stopped or hibernated instance receives a new public IP address when it is started.
AWS releases your instance's public IP address when you associate an Elastic IP address with it. When you disassociate the Elastic IP address from your instance, it receives a new public IP address.
To answer your original question: You don't need to worry about an EC2 instance regularly changing its IP address because as long as it keeps running and you don't explicitly change the associated IP address yourself, the IP address will remain static.
If you want to retain a public IP address that persists even after hibernating, stopping, or terminating the instance, you can attach an Elastic IP address.
For more information see: What are Elastic IP addresses, and how do I use them?

Assign my own /24 address to EC2 instance

I'm currently renting a /24 address block and would like to assign an IP Address from that block to one of my EC2 instances. I heard from a friend a while back that this can be done, but I haven't yet found a way to do it using Elastic IP or through an EC2 instances IP settings.
It is not possible to bring your own range of Public IP address to AWS.

How to tell if an IP address in Amazon's cloud is static?

Given an address (not owned by me) which is part of Amazon's Cloud, is there any way I can tell if that address is "elastic" (static)?
There is no way to tell if an IP is static(elastic) or not. AWS publishes a list of CIDRs that it owns and updates it periodically, but no information on if the addresses are elastic or not.
If the address is owned by you, then you can call describe-addresses and check if the IP is in the output. But if you don't own it, there is no way to tell if the address is elastic or not.
AWS provides you the flexibility to get Elastic Ip addresses in 2 ways
if generated with Elastic Ip console, yes it is static and completely owned by you, unless you delete it or re-associate it.
If you are referencing to Auto Assigned Elastic Ip address with EC2/ELB, they are not static. you get a new ip address everytime you restart the instance/add or remove the instance from ELB.
Elastic Ip addresses are associated to instances, which already have an IP address(static until instance terminated)

Elastic IP Address is being dissociated after a restart

I have an EC2 Instance with a Public IP associated.
For no reason, after a restart, this association is lost and I have to reassociate.
It doesn't happen for every restart.
Any tips?
There are two types of public IP addresses available for Amazon EC2 instances:
A Public IP address that is randomly assigned to an instance from a pool of available addresses. If an instance is stopped and later started, it might receive a different public IP address. (Restarting an instance will not cause this to happen, so I suspect that you stopped your instance rather than merely restarted it.)
An Elastic IP address that can be allocated to your account. The address can then be allocated to an EC2 instance. The IP address is static, so it will not change. However, it can be reassigned to a different EC2 instance if desired. It remains associated with the account until it is released.
If you are saying that you were using an Elastic IP address, then it should remain associated with the instance until specifically dissociated. It will not dissociate without a specific request. If it is being dissociated, then you could use AWS CloudTrail to look for the API call that would have caused this to happen.
In AWS EC2, By default the EC2 instances are not assigned with static public IP address.
For that, you will have to generate a Static IP address first and then assign it to your EC2 instance. In this way, even after the restart, it will retain the allocated static IP address.
To do this, Navigate to EC2 service, select 'Elastic IPs' from the left menu. Click on Allocate Elastic IP address. This will generate the static IP address. Now to allocate this to your instance, select the checkbox against the newly generated IP address, and click on Actions and 'Associate Elastic IP address'
Hope this helps :)