The reason your EC2 instance doesn’t have a public DNS is that the “DNS hostname” setting is disabled in your VPC where the EC2 instance is hosted. You can enable public DNS name for your EC2 instance by following below steps –
Step 1: Log in to your AWS management console.
Step 2: Navigate to EC2 service and select your EC2 instance.
Step 3: Click on “VPC” under the “Details” tab which will navigate you to the VPC where your EC2 instance is hosted.
Step 4: From “Actions” click on “Edit DNS hostname”.
Step 5: Enable “DNS Hostname” and click “Save changes”
Your EC2 instance should now have a public DNS name assigned to it.