简体   繁体   中英

Amazon ec2 instance unable to resolve domain

I have an ec2 instance that is unable to resolve any domains. So I'm unable to connect to any third party domains from my server.

For example when i ping google.com

平服务器
But when i ping the ip it work fine. The security group allows outbound traffic.

Additional details:
Os: Ubuntu 16.04.2 LTS

If someone could please point out what am i missing

Thanks in advance:)

This should go to 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.

Linux cannot resolve DNS names if there are no entries in resolv.conf, You should look if you have entries in /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

Thank you so much. It is working now. workaround you could run echo "nameserver 8.8.8.8" >> /etc/resolv.conf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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