Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EC2 could not resolve private DNS host name

I am new to Amazon Web Service (AWS)

I just created a VPC and and a subnet, which is inside it. However, I could not resolve any hostnames in this subnet (when I stay in any hosts in this subnet)

[ec2-user@ip-192-168-1-86 ~]$ nslookup
> ip-192-168-1-86.ec2.internal
Server:     192.168.1.2
Address:    192.168.1.2#53

** server can't find ip-192-168-1-86.ec2.internal: NXDOMAIN

I have double check that DNS resolution is enabled for my VPC and private DNS hostname is correct enter image description here

like image 596
Nguyễn Trí Avatar asked Sep 05 '25 03:09

Nguyễn Trí


1 Answers

From the AWS DNS documentation

When you launch an instance into a VPC, it always receives a private DNS hostname.

The DNS resolution depends on the enableDnsHostnames and enableDnsSupport flags.

By default, both attributes are set to true in a default VPC or a VPC created by the VPC wizard. By default, only the enableDnsSupport attribute is set to true in a VPC created any other way.

Depending upon the enableDnsHostnames and enableDnsSupport flags following rules apply:

If both attributes are set to true, the following occurs:

  • Instances with a public IP address receive corresponding public DNS hostnames.
  • The Amazon Route 53 Resolver server can resolve Amazon-provided private DNS hostnames.

If either or both of the attributes is set to false, the following occurs:

  • Instances with a public IP address do not receive corresponding public DNS hostnames.
  • The Amazon Route 53 Resolver cannot resolve Amazon-provided private DNS hostnames.
  • Instances receive custom private DNS hostnames if there is a custom domain name in the DHCP options set. If you are not using the Amazon Route 53 Resolver server, your custom domain name servers must resolve the hostname as appropriate.

If enableDnsHostnames and enableDnsSupport are true then check if the DHCP option set is modified.

  • Go to the VPC service page in the AWS Console. Select Your VPCs to see all the VPCs.
  • Select the VPC, and select Actions, Edit DHCP options set.
  • In the DHCP options set list, select the default DHCP option list, and then choose Save.

On the VPC service page, you can find the DHCP Options Sets where you can get the Default DHCP Options Sets.

It would take a couple of hours for the running EC2 instances to reflect this without a restart. You can also renew the IP lease by the following command.

  • Windows: ipconfig /renew
  • Linux: sudo dhclient -r

Or restart the instance, if you can't wait.

like image 132
GSSwain Avatar answered Sep 10 '25 12:09

GSSwain