EC2 in public subnet reachable by public IP but not by public DNS

0

When launching ec2 instance in a specific public subnet, the instances automatically show a Public IPv4 address and a Public IPv4 DNS. However, they are only reachable (by SSH) through their IP address; not through their DNS name. What could be the cause? Some additional information:

The VPC containing the subnet has "DNS hostnames" enabled and "DNS resolution" enabled. The Subnet ACL allows all traffic.

6개 답변
1

Hi there!

When you say they are only reachable by IP you mean with SSH only? And when you say "not by DNS" do you mean HTTP/S? If you it might be because the security group attached to the instance is not allowing HTTP traffic.

To modify the security group:

  1. Open the EC2 console
  2. Go to Instances
  3. Locate the instance in question
  4. Look at the instance details and under the Security tab, click on the security group link
  5. This will take you to the security group details

EC2 Instance Security Group

  1. Edit the inbound rules
  2. Add a rule to allow HTTP (or HTTPS) for your instance.

Security Group Inbound Rules

I hope this helps (if so, please accept this answer)

profile pictureAWS
전문가
답변함 일 년 전
profile picture
전문가
검토됨 일 년 전
0

Hi, thanks for your reply. Maybe I didn't describe it clearly, sorry. I have released all ports and protocols under inbound rules. But the public DNS is still inaccessible. I found through the ping command that the ip address pointed to by the public DNS is not the public ip of the instance。 My public ip can access http and ssh services normally. The difference is that the ip resolved by the public DNS is inconsistent with the public ip

답변함 일 년 전
0

Can I check the public DNS from the EC2 details?
You should be able to see the public IP by running the nslookup command on this public DNS.
ec2

profile picture
전문가
답변함 일 년 전
0

Thank you very much for your help. I have checked the cause. The port belonging to the security group is not released and the nginx configuration file does not take effect. However, the inconsistency between the ping public dns and public ip addresses has caused me to never find the real reason. Can you tell me why it is inconsistent? I am very curious.

답변함 일 년 전
0

On the client machine (where you are running the SSH session from), what results do you get from doing a DNS lookup for the EC2 instance?

You can use nslookup or dig to test, or even just trying to ping the instance. Does it return the IP address? If not, then there is an issue with the DNS resolution from that machine - further troubleshooting is required. If it does return the IP address then perhaps there is an issue with the SSH client software where it isn't doing DNS "correctly".

profile pictureAWS
전문가
답변함 일 년 전
-1

I would think that is strange but being DNS there might be other elements at play.

The best recommendation I can provide to you is to use an Elastic IP to get a permanent public IP for your instance which will provide you with a new DNS name. As mentioned, it is permanent and won't change even if you terminate your instance and can detach it from the Instance and attach it to another one if needed.

profile pictureAWS
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠