为搬瓦工VPS修改DNS以解锁ChatGPT

2025-02-06更新:

最近在搬瓦工的VPS上执行resolvectl query chatgpt.com时,发现返回的已经是172.31.255.2了,所以可能后续不需要指定DNS了。

参考文章:

  • 持久化DNS配置 | 瓦工机器没有解锁ChatGPT的用户请尝试
  • Ubuntu 20.04设置DNS解析(解决resolve.conf被覆盖问题)

24年年初的时候,看到搬瓦工补货的消息,马上就入手了一个年付$49.99的SPECIAL 10G KVM PROMO V5 - LOS ANGELES - CN2 GIA LIMITED EDITION,但是在之后的使用过程中,我发现只能使用网页端的ChatGPT,而无法使用iOS端的ChatGPT,前几天偶然看到了NodeSeek上的一篇文章,我对着操作了一下,发现确实可以成功解锁iOS端的ChatGPT,所以记录一下。

操作

所有的操作均在Ubuntu20.04系统下进行,系统不同操作可能也会有些许差异,具体操作流程如下:

  1. 先查询访问ChatGPT时返回的结果是什么:

    1
    resolvectl query chatgpt.com

    结果可能为:

    1
    2
    3
    4
    5
    chatgpt.com: 172.64.155.209                    -- link: eth0
    104.18.32.47 -- link: eth0

    -- Information acquired via protocol DNS in 9.7ms.
    -- Data is authenticated: no

    这说明在访问ChatGPT时返回的是ChatGPT的真实IP,而非搬瓦工提供的解锁DNS IP;

  2. 然后编辑/etc/systemd/resolved.conf文件,打开文件后其中内容为:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    #  This file is part of systemd.
    #
    # systemd is free software; you can redistribute it and/or modify it
    # under the terms of the GNU Lesser General Public License as published by
    # the Free Software Foundation; either version 2.1 of the License, or
    # (at your option) any later version.
    #
    # Entries in this file show the compile time defaults.
    # You can change settings by editing this file.
    # Defaults can be restored by simply deleting this file.
    #
    # See resolved.conf(5) for details

    [Resolve]
    #DNS=
    #FallbackDNS=
    #Domains=
    #LLMNR=no
    #MulticastDNS=no
    #DNSSEC=no
    #DNSOverTLS=no
    #Cache=yes
    #DNSStubListener=yes
    #ReadEtcHosts=yes

    我们需要更改其中的DNSFallbackDNS两行,将其修改为:

    1
    2
    DNS=172.31.255.2
    FallbackDNS=8.8.8.8 1.1.1.1

    保存文件;

  3. 重启服务:

    1
    systemctl restart systemd-resolved

  4. 再次查询访问ChatGPT时返回的结果:

    1
    2
    3
    4
    chatgpt.com: 172.31.255.2                      -- link: eth0

    -- Information acquired via protocol DNS in 2.5ms.
    -- Data is authenticated: no

  5. 更换成功,可以打开iOS端的ChatGPT尝试是否可以正常访问。

原理

Ubuntu通过读取/etc/resolv.conf中的信息来确定DNS服务器,可以查看一下该文件内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0

可以看到在第一行就有Do not edit.的字样,所以需要通过修改/etc/systemd/resolved.conf文件来达到修改DNS服务器的目的。