LUREN
V2EX  ›  问与答

有没有办法获得不同地区的 DNS 解析结果?

  •  
  •   LUREN · May 30, 2020 · 3518 views
    This topic created in 2361 days ago, the information mentioned may be changed or developed.

    假如一个网站使用了 CDN,它有多个地区节点。在国内解析获得的是美国 IP,在香港解析获得的是香港 IP 。

    在没有香港服务器的情况下,有没有办法可以查询到香港地区的解析 IP 呢?

    手动查询可以用 https://ping.chinaz.com/ 这类网站,但我需要在 shell 脚本里自动查询。

    请问有没有一些在线 ping 网站的 api 可以使用或者其它办法可以解决这个问题?找了一圈都没有发现。。

    Supplement 1  ·  May 30, 2020
    感谢大家的回复!经过测试,似乎还是要找个香港 dns 服务器来解析才行。

    使用 Google dns 和 cloudflare dns,虽然指定了 subnet 参数,但还是根据请求位置返回的。

    例如这是一个示例,它还是解析美国 IP 。

    <PRE>curl -i 'https://dns.google/resolve?name=a356.w10.akamai.net&type=a&do=1&edns_client_subnet=63.223.17.0/24'</PRE>

    如果指定一个香港 dns 服务器解析,返回就是香港 IP 了。

    <PRE>dig @210.0.255.251 a356.w10.akamai.net +subnet=63.223.17.0/24 +short</PRE>

    不知大家还有没有其它办法,或者有没有比较稳定的香港 dns 服务器分享?
    13 replies  •  2020-05-30 16:17:34 +08:00
    3CH0
    3CH0
    May 30, 2020
    1
    dig @223.5.5.5 www.aliyun.com +subnet=47.75.18.0
    reus
    reus
    May 30, 2020
    2
    查询当地的 DNS 服务器,有些基于 https 也会有地域参数
    JinShu
    JinShu
    May 30, 2020 via Android
    3
    JinShu
    JinShu
    May 30, 2020 via Android
    4
    @haimall 无视我把,只看了标题
    ddefewfewf
    ddefewfewf
    May 30, 2020
    5
    dnsmasq
    Jerami
    Jerami
    May 30, 2020 via Android
    6
    whatismydns
    LUREN
    LUREN
    OP
    May 30, 2020
    7
    @3CH0 感谢!测试有效。不过 +subnet 指定查询位置似乎不总是有效,是需要取决 dns 服务器支持吗?测试 8.8.8.8 和 1.1.1.1 不起作用,223.5.5.5 存在污染问题,有其它 dns 推荐吗?
    LUREN
    LUREN
    OP
    May 30, 2020
    8
    @reus 请问有香港 dns 推荐吗?
    orcusfox
    orcusfox
    May 30, 2020
    10
    没看到要脚本,忽略我吧
    Showfom
    Showfom
    PRO
    May 30, 2020
    11
    dig + 一台支持 ECS 的递归 DNS 服务器即可,公共服务的话国内 223.5.5.5 国外 8.8.8.8

    你还要解决污染,又要在国内做,那就自己搭建去呗
    Livid
    Livid
    MOD
    PRO
    May 30, 2020
    12
    https://developers.google.com/speed/public-dns/docs/doh/json

    用 DNS-over-HTTPS 的 JSON API,里面有 edns_client_subnet 支持。
    LUREN
    LUREN
    OP
    May 30, 2020
    13
    @Livid
    curl -i 'https://dns.google/resolve?name=a356.w10.akamai.net&type=a&do=1&edns_client_subnet=63.223.17.0/24'
    测试与 dig +subnet= 参数一样,虽然指定了一个香港子网,但没有解析没有返回香港 IP 。似乎还是取决 dns 服务器行为,换了一个香港 dns 就可以了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4354 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 08:23 · PVG 16:23 · LAX 00:23 · JFK 03:23
    ♥ Do have faith in what you're doing.