dig,host,nslookup,chrome browser can resolve hostname,curl can't [closed]

ghhaqwfi  于 2023-03-23  发布在  其他
关注(0)|答案(1)|浏览(150)

**已关闭。**此问题为not about programming or software development。当前不接受答案。

此问题似乎与a specific programming problem, a software algorithm, or software tools primarily used by programmers无关。如果您认为此问题与another Stack Exchange site的主题有关,您可以留下评论,说明在何处可以回答此问题。
3个月前关闭。
Improve this question
macOS Ventura(13.0.1)
使用4km3/dnsmasq在我的本地机器上启动DNS服务器。使用子网10.6.0.0/16并分配静态IP 10.6.0.2。我已经在网络设置中添加了DNS服务器IP地址。
事情是这样的

$ dig +short my.domain.test
10.6.0.6
$ host my.domain.test
my.domain.test has address 10.6.0.6
$ nslookup my.domain.test
Server:     10.6.0.2
Address:    10.6.0.2#53

Name:   my.domain.test
Address: 10.6.0.6

$ curl -i -v -4 my.domain.test
* Could not resolve host: my.domain.test
* Closing connection 0
curl: (6) Could not resolve host: my.domain.test

当它不工作时,DNS服务器似乎不会被查询。
我发现了很多关于这个问题的文章,但是没有一个能解决我的问题。为了让API调用正常工作,我需要这个来处理curl
[It适用于Chrome浏览器,不适用于Safari]

ntjbwcob

ntjbwcob1#

事实证明,curl并不关心本地DNS。域名需要存在于互联网上。curl在根服务器中查找记录。因此,即使您的DNS记录解析,您也无法以您想要的所有方式访问它们。有些可以工作,有些不行。
一个解决方案是,注册一个实际的域名。然后将域名指向您的私有IP地址或任何您想要指向的地址。您可以在本地计算机上安装额外的DNS服务器。

相关问题