我有一批亚马逊EC2实例。今天,出于我无法确定的原因,其中三个实例无法解析特定的URL。当我尝试使用“curl ”时,这三个实例会显示“curl:(6)无法解析主机”,而所有其他实例都能够解析该URL并返回正确的数据。仅限于特定的URL - 所有其他URL均正常工作。
这是什么原因造成的?我没有更改任何实例上的内容,所以不是我的问题。我该如何找出发生了什么?
这是什么原因造成的?我没有更改任何实例上的内容,所以不是我的问题。我该如何找出发生了什么?
sudo systemctl enable --now systemd-resolved.service
检查并比较运行正常和不正常主机的/etc/resolv.conf
(适用于Linux实例)。以下是我Linux实例的信息:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 10.0.0.2
search us-west-2.compute.internal
对于Windows实例,请检查并比较工作和非工作主机之间的DNS条目的ipconfig /all
命令输出。以下是来自我的Windows实例的信息:
Windows IP Configuration
Host Name . . . . . . . . . . . . : WIN-************
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : us-west-2.ec2-utilities.amazonaws.com
ec2.internal
us-east-1.ec2-utilities.amazonaws.com
compute-1.internal
us-west-2.compute.internal
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : us-west-2.compute.internal
Description . . . . . . . . . . . : Citrix PV Ethernet Adapter #0
Physical Address. . . . . . . . . : 02-E6-AB-83-C6-8A
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 10.0.0.251(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Friday, March 21, 2014 11:36:17 AM
Lease Expires . . . . . . . . . . : Tuesday, March 25, 2014 5:07:59 AM
Default Gateway . . . . . . . . . : 10.0.0.1
DHCP Server . . . . . . . . . . . : 10.0.0.1
DNS Servers . . . . . . . . . . . : 10.0.0.2
NetBIOS over Tcpip. . . . . . . . : Disabled
如果您没有使用默认的VPC或VPC向导创建的VPC,则需要确保启用DNS主机名
和DNS解析
选项。
/etc/resolve.conf
文件被清空,然后就无法解析主机。resolve.conf
。这里是我核实事项的清单。您是否百分之百确定没有任何人/任何事物更改了以下内容:
Seb
请确保 VPC 启用了以下配置
DNS 解析:已启用
DNS 主机名:已启用
同时,确保正确设置了附加到 VPC 的 DHCP 选项。
gclib
,这会导致某些软件包的名称解析丢失。在我的情况下是ffmpeg
。nscd
来解决这个问题:yum update -y
yum install nscd -y
service nscd start
这个答案很可能会解决您的问题,就像解决我的问题一样。您必须修复您的hosts文件。
127.0.0.1 localhost.localdomain localhost
127.0.1.1 my-machine
或者
127.0.0.1 localhost
127.0.1.1 my-machine
其中my-machine是出现在错误信息结尾处的主机名。
(例如,我的是domX-A2-33-D9-CB-F4-A8
)
请不要忘记在更改hosts文件后从管理控制台重新启动实例。;)
重新安装resolvconf后它就可以工作了。
sudo apt-get install --reinstall resolvconf