I have an instance inside a VPC with DNS hostnames & DNS resolution enabled
Today, each instances I spawn get the hostname & Private IP DNS name as
ip-xx-xx-xx-xx.ec2.internal
The problem with this is everytime my instance is terminated and I have to replace it, the IP address is going to change. Other machines in the same VPC need a deterministic way to access this instance. e.g. by connecting to mymasterinstance.dev. Any idea how do I give an internal / private DNS for my instance?
Private IP addresses on Amazon EC2 instances do not change. Therefore, the other machines could simply reference the private IP address.
Alternatively, you can create a "Private hosted zone" in Amazon Route 53 and create an A-Record to associate a domain name (eg mymasterinstance.dev) with the private IP address of the instance.
The public IP address on an instance will change when the instance is Stopped and Started (but will not change when the instance is Rebooted). If you require a static public IP address, you can create an Elastic IP Address and associate it with the instance.
Another perhaps simpler way to do this is to add a second IP address to your EC2 instance. When you terminate an instance, and add back a "replacement" instance, set its second IP address to what the terminated instance's second IP address was. Then you can do all of your referencing directly by IP address and you have full control over that second IP address. None of your configs needs to change.
Related
I have an instance running on AWS. I have stopped it and then restarted it after few hours. Now I am unable to access my website by a domain name but it is accessible by its ip
Looking for a solution so that I am able to access it with domain name also.
As this is your personal domain, the likely scenario is that when your instance rebooted the IP address changed.
You can validate this by comparing the public IP address in the AWS Console to the IP address entered in your DNS configuration for your domain.
This is expected behaviour for the standard public IP address for EC2 hosts, if you want to resolve this you will need to create an elastic IP address and associate it to the instance you have.
Once this has been associated update your DNS record to use the new public IP that has been assigned (the EIP). This will then allow you to reboot your instance without the risk of losing your IP. In addition be aware that based on the TTL of your domain you will need to wait for the DNS to propagate.
Is there a way to reconfigure the previous instance's IP address to the newly assigned IP address.
After I configured all my instance and I tried to assign the elastic IP. I found that the IP is changed. therefore the website under apache2 /var/www/html was no longer valid / unreachable.
is there any way that I can change old IP to new IP address?
NEW: ec2-13-237-246-127.ap-southeast-2.compute.amazonaws.com
will redirect to
OLD:http://ec2-54-206-98-171.ap-southeast-2.compute.amazonaws.com/
since I changed to associate a new IP into this instance.
Unfortunately, you can not reuse that public IP address.
A public IP address is assigned to your instance from Amazon's pool of public IPv4 addresses, and is not associated with your AWS account. When a public IP address is disassociated from your instance, it is released back into the public IPv4 address pool, and you cannot reuse it.
If you require a persistent public IP address that can be associated to and from instances as you require, use an Elastic IP address instead
The old DNS will not be available. These DNS entries are auto generated by AWS. If you notice the format, you would see,
ec2-<ip-address>.<region>.compute.amazonaws.com.
If you want a static DNS name, you must created a domain, add an address record pointing to your instance's public IP.
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.
I created an Ubuntu instance in AWS. I assigned an IP address from which I can connect to the instance from outside using PuTTY. Now I've changed my location and my IP address is different so I cannot connect to the instance with PuTTY any more. I'm trying to add another IP address (my current IP) to the instance network settings but for some reason AWS says it cannot accept the address:
IP Address not in Subnet
What does it mean? Why does it require an address in Subnet?
My questions are:
How to bypass it? or
How to change settings so that it could accept any arbitrary IP I provede? or
How to include any arbitrary IP into the Subnet of addresses? or
How can I just change previous initial address to a new one?
Your question is somewhat confusing, so I'll list my assumptions as I go along.
I assigned an IP address from which I can connect to the instance from outside using PuTTY
Are you talking about Elastic IP, and connecting to the instance from the internet? If so, it is irrelevant to being able to assign private IP.
Now I've changed my location
What does it mean? The location of EC2 instance? Like, a different region or something?
my IP address is different
The IP of the instance, right? So, why can't you connect to this new IP?
The bottom line, you can add another private IP on the same subnet. That will not allow you to connect to a diiferent private IP, if you can't connect to original IP. If you are trying to do something different, please clarify!
I accidentally found the reason of an issue. It has nothing to do with private IP addresses.
"Security groups" are responsible for connection to the instance from outside (from internet using PuTTY). Since my IP has changed I have to reflect it in settings for the instance. See the "Security groups" of your instance and then select the appropriate to adjust:
In PuTTY:
Host name (or IP address) field: ubuntu#Public DNS or Public IP of your instance
Connection > SSH > Auth: use ssh2dsa.ppk or ssh2rsa.ppk, both seems to work fine
I have a server that is up and running with an auto-assigned public IP address. This IP address was not created with Elastic IP. Is there anyway to transfer this IP address onto a new instance in my account?
I'm afraid you can't.
The auto assigned public IPs are not yours to deassociate and reassociate.
You can't tell them "I changed my mind, I want to use this IP as if it was an Elastic IP". It doesn't work like that. You can't really pick your elastic IP. You just ask for one, and then operate with whatever IP they gave you.
You cannot manually associate or disassociate a non-elastic IP address from your instance. Instead, in certain cases, aws release the public IP address from your instance, or assign it a new one for below cases:
1. They release the public IP address for your instance when it's stopped or terminated. Your stopped instance receives a new public IP address when it's restarted.
They release the public IP address for your instance when you associate an Elastic IP address (EIP) with your instance, or when you associate an EIP with the primary network interface (eth0) of your instance in a VPC. When you disassociate the EIP from your instance, it receives a new public IP address.
If the public IP address of your instance in a VPC has been released, it will not receive a new one if there is more than one network interface attached to your instance.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html#concepts-public-addresses
If you require a persistent public IP address that can be associated to and from instances as you require, use an Elastic IP address (EIP) instead. You can allocate your own EIP, and associate it to your instance. For more information, please see Elastic IP Addresses (EIP).
Easy, setup a HTTP or TCP transparant proxy, with HAProxy or Nginx.