example.com 的子域只能从我的网络的Intranet进行查询(nslookup仅在该网络内响应)。问题是我在网络内部,并且nslookup可以正确响应,但是socket.gethostbyname引发了异常。
nslookup 命令返回:
Server: 172.16.11.200
Address: 172.16.11.200#53
Non-authoritative answer:
example.example.com canonical name = example-elb-174457708.eu-west-1.elb.amazonaws.com.
socket.gethostbyname 返回:
python -c "import socket; print(socket.gethostbyname_ex('example.example.com'))"
Traceback (most recent call last):
File "<string>", line 1, in <module>
socket.gaierror: [Errno -2] Name or service not known