简体   繁体   English

Amazon ec2 实例无法解析域

[英]Amazon ec2 instance unable to resolve domain

I have an ec2 instance that is unable to resolve any domains.我有一个无法解析任何域的 ec2 实例。 So I'm unable to connect to any third party domains from my server.所以我无法从我的服务器连接到任何第三方域。

For example when i ping google.com例如当我 ping google.com

平服务器
But when i ping the ip it work fine.但是当我 ping ip 时它工作正常。 The security group allows outbound traffic.安全组允许出站流量。

Additional details:额外细节:
Os: Ubuntu 16.04.2 LTS操作系统:Ubuntu 16.04.2 LTS

If someone could please point out what am i missing如果有人可以请指出我错过了什么

Thanks in advance:)提前致谢:)

This should go to SuperUser/ServerFault. 这应该转到SuperUser / ServerFault。 Please see here 请看这里

To resolve a domain name to IP, you would need a nameserver, Linux would look at /etc/resolv.conf for the nameserver. 要将域名解析为IP,您将需要一个名称服务器,Linux会在/etc/resolv.conf查找该名称服务器。

Linux cannot resolve DNS names if there are no entries in resolv.conf, You should look if you have entries in /etc/resolv.conf. 如果resolv.conf中没有条目,则Linux无法解析DNS名称。您应该查看/etc/resolv.conf中是否包含条目。

root@ip-10-116-131-184:~# mv  /etc/resolv.conf /etc/resolv.conf.bk
root@ip-10-116-131-184:~# ping google.com
ping: unknown host google.com
root@ip-10-116-131-184:~# mv  /etc/resolv.conf.bk /etc/resolv.conf
root@ip-10-116-131-184:~# ping google.com
PING google.com (172.217.13.238) 56(84) bytes of data.
64 bytes from iad23s61-in-f14.1e100.net (172.217.13.238): icmp_seq=1 ttl=47 time=1.63 ms
64 bytes from iad23s61-in-f14.1e100.net (172.217.13.238): icmp_seq=2 ttl=47 time=1.04 ms

As your workaround you could run echo "nameserver 8.8.8.8" >> /etc/resolv.conf 8.8.8.8 is google public DNS 作为您的解决方法,您可以运行echo "nameserver 8.8.8.8" >> /etc/resolv.conf 8.8.8.8是google public DNS

Thank you so much.太感谢了。 It is working now.它现在正在工作。 workaround you could run echo "nameserver 8.8.8.8" >> /etc/resolv.conf解决方法你可以运行 echo "nameserver 8.8.8.8" >> /etc/resolv.conf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM