I have standard AWS EC2 instance. It has standard URL that was created by AWS automatically on EC2 creation:
ec2-xx-xx-xxx-xx.ap-southeast-2.compute.amazonaws.com
I want to change host name for arbitrary value and it is not a public domain. And I want to access EC2 from Internet with that custom host name:
Instead: ec2-xx-xx-xxx-xx.ap-southeast-2.compute.amazonaws.com
I want at least: foo.ap-southeast-2.compute.amazonaws.com
Or even better: foo.compute.amazonaws.com
Is it possible in AWS?
I want to change host name for arbitrary value and it is not a public
domain. And I want to access EC2 from Internet with that custom host
name ... EG foo.ap-southeast-2.compute.amazonaws.com
Is it possible in AWS?
No, it is not. The external DNS hostname is the authoritative DNS name for that instance. That "ec2-xx-xxx-xxx-xx" part is the IP # assigned for that instance. That hostname stays with that IP number/instance as long as it is assigned to it.
Each instance that receives a public IP address is also given an
external DNS hostname; for example,
ec2-203-0-113-25.compute-1.amazonaws.com. We resolve an external DNS
hostname to the public IP address of the instance outside the network
of the instance, and to the private IP address of the instance from
within the network of the instance.
Using DNS, of course you can alias that DNS hostname to any host in a custom domain. But you cannot modify the AWS given external DNS hostname.
See Public IP Addresses and External DNS Hostnames
Related
Traditionally, the purpose of a DNS server is to translate human-friendly hostnames into IP addresses. More importantly, it allows for the updating of a service's location (IP address) on the network while retaining the same hostname.
In EC2 however, the public DNS hostname is linked to its public IP address. For example, if the IP address of an instance is 1.2.3.4, its DNS name would be ec2-1-2-3-4.compute-1.amazonaws.com.
As the DNS name is syntactically linked to its IP, it wouldn't serve as a memorable URL nor allow the IP to change independently of its DNS name.
What could be the reason AWS provides the DNS name? What purpose does the DNS name serve in the context of EC2? What can I accomplish with the public DNS hostname that I can't with the public IPv4 address?
One advantage to using the public hostname instead of the private IP is actually the magic translation to IP address.
If you're inside of AWS and you use the public hostname it will resolve to the private IP, whereas if you're outside of AWS it will resolve to the public IP. Some users will create a CNAME for a specific host that resolves to the public hostname of the EC2. Then when one of their applications connect to this hostname it will route to the private IP, which will avoid all public transit.
Each instance that receives a public IP address is also given an external DNS hostname; for example, ec2-203-0-113-25.compute-1.amazonaws.com. We resolve an external DNS hostname to the public IP address of the instance from outside its VPC, and to the private IPv4 address of the instance from inside its VPC
Outside of this feature it is a regular domain record that is supplied to provide a user with either IP or 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.
I registered a domain name with AWS Route 53 as mydomain.com. Is there anyway that I can assign e.g. ns1.mydomain.com as a public hostname to an EC2 which does NOT have a Elasti IP?
Thanks
You can assign the domain name to any IP address of an instance. However be aware of the following limitations:
If a domain name is assigned to a private IP, it will not be connectable without network access to that IP
If the domain is assigned to a non-elastic public IP if the instance stops and starts you would lose the public IP so would need to update the DNS resolution.
If you have a public facing application, but want to keep network traffic that directly connects to the instance private you should look at using an ELB in front of the application to provide a security boundary between the internet and your application.
Utilize a load balancer in front of the instance and assign the public hostname to the load balancer.
Use S3 webpage redirect and assign the hostname to the S3 URI.
If the problems is that you don't have any elastic IP's left, you can request for more. This should be resolved within about 15 minutes.
We got an issue in penetration testing, that fully qualified Host Name ec2-IpAddress.example.amazonaws.com is being exposed, Can anyone help to fix this issue.
You need to disable DNS host names on your VPC subnet.
If your VPC is enabled to support DNS hostnames, each instance that
receives a public IP address or an Elastic IP address is also given a
public DNS hostname. We resolve a public DNS hostname to the public IP
address of the instance outside the instance network, and to the
private IP address of the instance from within the instance network.
For more information, see Using DNS with Your VPC.
See https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-ip-addressing.html#vpc-public-ipv4-addresses
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.