DNS(Domain Name System),即域名系统,是互联网的一项核心服务,它作为将域名和IP地址相互映射的一个分布式数据库,能够使人更方便地访问互联网。DNS使用TCP和UDP端口53。
ipconfig /flushdns
命令),更改DNS服务器。import dns.resolver
def query_dns(domain):
try:
answers = dns.resolver.resolve(domain, 'A')
for rdata in answers:
print(f'{domain} resolves to {rdata}')
except dns.resolver.NXDOMAIN:
print(f'The domain {domain} does not exist.')
except dns.resolver.NoAnswer:
print(f'The domain {domain} has no A records.')
except dns.resolver.Timeout:
print(f'The query for {domain} timed out.')
# 示例查询
query_dns('www.example.com')
请注意,以上代码和链接仅供参考,实际使用时可能需要根据具体情况进行调整。
领取专属 10元无门槛券
手把手带您无忧上云