AWS EC2 Rescue - Get old Public DNS back - amazon-web-services

I ran the rescue program to generate a new private key for my AWS EC2 instance. There seems to be a new instance with the same old instance-id but a new public DNS. Is there a way I can get back to my old public DNS? Everything I had was written to call the old public DNS (server name url) .... Thank you. (AWS documentation is very hard to follow.)

The only way to 'keep' a public IP address is to create an Elastic IP. This is a static IP address that is associated with your AWS Account and can be assigned to an Amazon EC2 instance.
Typically, it is best to avoid requiring a specific IP address. This can be done by using a DNS name that resolves to an IP address, thereby allowing the IP address to change.
However, sometimes people need a static IP address for whitelisting (eg calling an API from a 'known' IP address). Elastic IPs are available for this purpose.

Related

AWS private elastic ip

I have a scenario where I want to setup an haproxy cluster with keepalived. I saw this blog post https://www.peternijssen.nl/high-availability-haproxy-keepalived-aws/ and its pretty detailed and easy to follow, but for my scenario I need the elastic IP's to be private. Is this doable ? As from AWS documentation Elastic IP's are only public IPs.
I need a floating IP which will act as a floating cluster IP. What can I use if Elastic IP is not an option.
An elastic IP within AWS is actually a static public IP address. This functionality is required as by default a public IP address is not reserved by an account, and when enabled limits the total IPv4 addresses you can keep.
For private address ranges however, your instances can be assigned any private IP address that is within any of your VPCs CIDR range(s).
In fact for this reason you can select almost any IP address found within your VPC when launching a new instance, in addition the IP addresses that are attached to an EC2 instance are static and will be attached to that instance until it is terminated.
Therefore as long as you don't terminate the instances the private IP(s) will be maintained. However, in the event the instance fails and is not recoverable you would still need to launch a new instance and use that IP.
It might be more beneficial using a DNS record to resolve the IP just in case of an emergency, or failing that use a load balancer to distribute traffic.
For this case you can provision an Elastic Network Interface (ENI) with a static private IP address which you can attach/re-attach to EC2 instances. As long as you don’t delete the ENI, it will retain the I as p address. Find out more here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html

AWS instance accessible by IP only and not with domain name

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.

AWS elastic IP vs public IP

I am new to AWS and tried to create an EC2 instance.
I have a domain and ready to modify the A record to the associated EC2 instance.
I found an article that said an elastic IP is required for associating a production domain.
But AWS provides a public IP and it is accessible on the public internet too (i know it changes after restart, just assuming its okay to modify the A record after the machine is restarted - actually it is not restart very often).
In this case, is it a must that to assign an elastic IP to the instance (this instance contains no load balancing, it is only a simple single instance)?
If yes, why is it necessary?
An Elastic IP (EIP) is not necessary provided that you understand the limitations of public IPs. You may not reboot your instance, but AWS might for any number of reasons. This means that the public IP address could change when you are not expecting it.
When an EIP is assigned to a running EC2 instance, there are no charges for the EIP e.g. it is free. Therefore why go thru the hassle of needing to monitor your public IP address.

Keeping the same Public DNS for an EC2 Instance

I understand, that a static IPv4 addresses would be more expensive for AWS, so it changes every time I restart the instance. But the Public DNS could be static, so I would not have to change the address in all my applications, after restarting the Instance.
Can I statically set the Instances Public DNS to something like "MyChoosenName.eu-west-1-compute.amazonaws.com"?
It seems that AWS now allows keeping a static public IP address with a EC2 Windows or Linux instance by associating an Elastic IP address with the instance.
Check out their webpage for how to "allocate and associate an Elastic IP address with your EC2 Windows or Linux instance".
No its not possible
Because each public ip address in AWS is binded to DNS, so what you
are attempting add sub-domain to the
"eu-west-1-compute.amazonaws.com" which is not possible you are not
owner of the domain provider.
The thingh you do is bind the public to some other domain which you own like
Mychoicename.abc.com like we do for other domain bindings either in
AWS route53 or other domain providers.

Elastic IP changing IP and not associating with instance

I have created an Elastic IP. The IP address listed seems to be stable. It is associated with an instance. However, I get this weird behaviour:
The public DNS listed for that IP contains a different address than the literal IP address.
The public DNS does not resolve to the Elastic IP; it resolves to the IP implied by the DNS name.
Stopping and starting the instance changes the IP address.
I've tried creating a new elastic IP address and a new instance and associating them, and I experience the same bug. What's going on here?
I'm assuming you are looking at the AWS console, not the output of a program using the API directly.
The "public DNS" you see in the console is the public DNS of the instance, not of the elastic IP address. If the instance is associated with an ElasticIP, its public DNS should include the ElasticIP in it and resolve to the ElasticIP. Since it isn't, I suspect a bug in the AWS console. I've noticed a lot of lag in it showing the addresses when ElasticIP addresses are associated or disassociated. To confirm this, you might try completely clearing your browser history and cookies and reconnecting to the console, to see if the display is now right. Or you could use a browser's incognito or private browsing mode.
If you create the obvious public DNS to match your ElasticIP address, I'll bet it resolves correctly.
Yes, the public Elastic IP address is stable (which, of course, is why they exist).
Are you referring to the fact the DNS name will resolve to a different IP address depending on whether you are resolving inside or outside AWS?
If so, this is a feature not a "bug".
If you look up a host name from outside AWS you get the public IP. If you look up the same name from, say, the command line of an EC2 instance you get the private IP (typically a 10.0.0.0 address).
This means that you can refer to an instance by a single name but internal traffic is automatically routed over the local network and not over the (billable) public interface.