A guy I work with gave me the EC2 credentials to log onto his EC2 console. I was not the one who set it up. Some of the instances show a public dns name and others have a bl
I tried to fix the 'no public DNS' once the EC2 was up and running, I couldnt add a public DNS
this is even after following the above steps making mods to the VPC or the Subnet
so, I had to make modifications to the subnet and the vpc, before starting another instance, and THEN start up a new instance.
the new instance had a public DNS. That is how it worked for me.
First of all, there can be two reasons for this:
To solve this :
i) Go to AWS VPC console and select the VPC you have created.
ii) Then click on Actions and then enable DNS Resolution.
OR
Here you cannot change the setting; so create an ami image and then recreate the instance from that.
In my case I found the answer from slayedbylucifer and others that point to the same are valid.
Even it is set that DNS hostname: yes
, no Public IP is assigned on my-pvc (only Privat IP).
It is definitely that Auto assign Public IP has to be set
Enable
.
If it is not selected, then by default it sets toUse subnet setting (Disable)
If the instance is in VPC, make sure both "DNS resolution" and "DNS hostnames" is set to "yes". You can do this in the Aws console UI. HTH!
You don't have to assign public ip address to your instance. you can use NAT instances or NAT Gateway.
https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Scenario2.html https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-comparison.html
For those using CloudFormation, the key properties are EnableDnsSupport and EnableDnsHostnames which should be set to true
VPC: {
Type: 'AWS::EC2::VPC',
Properties: {
CidrBlock: '10.0.0.0/16',
EnableDnsSupport: true,
EnableDnsHostnames: true,
InstanceTenancy: 'default',
Tags: [
{
Key: 'env',
Value: 'dev'
}]
}
}